python 使用editplus.exe 打开所有指定文件

复制代码
# install beautifulsoup4
import os
import re
import chardet
import requests
import subprocess
from bs4 import BeautifulSoup

def IsArrayEmpty(list):
	return not list	

def ReadFile(strFilePath):#读取文件
	with open(strFilePath, 'rb') as f:
		varContent = f.read()
		encoding = chardet.detect(varContent)['encoding']
		varContent = varContent.decode(encoding)
		return varContent
	return ""

def ParseFile(path, strSearch):
	strData = ReadFile(path)
	nIndex = strData.find(strSearch)
	if nIndex != -1:
		editplus_path = "C:\\Program Files\\EditPlus\\editplus.exe"
		if os.path.isfile(path):
			#将文件的打开方式设定为EditPlus
			#将Editplus.exe 打开所有文件
			os.startfile(path)
			
def enumerate_folder(strFolder, strSearch):
    for root, dirs, files in os.walk(strFolder):
        for file in files:	
            path = os.path.join(root, file)	
            if path.find(".py") == -1:
                ParseFile(path, strSearch)
            else:
                print(path)
        for dir in dirs:
            pass		

enumerate_folder("./", "elecbook")

根据指定字符串查找到文档

相关推荐
2401_831824961 分钟前
编写一个Python脚本自动下载壁纸
jvm·数据库·python
2401_8579182911 分钟前
Python在2024年的主要趋势与发展方向
jvm·数据库·python
今儿敲了吗14 分钟前
python基础学习笔记第九章——模块、包
开发语言·python
lay_liu15 分钟前
ubuntu 安装 Redis
linux·redis·ubuntu
li星野26 分钟前
[特殊字符] Linux/嵌入式Linux面试模拟卷
linux·运维·面试
二闹31 分钟前
Python文件读取三巨头你该选择哪一个?
后端·python
独断万古他化33 分钟前
Python+Pytest 接口自动化测试实战 —— 抽奖系统接口测试框架设计与实现
python·pytest·接口自动化·测试·allure·yaml·json schema
沪漂阿龙34 分钟前
Python 面向对象编程完全指南:从新手到高手的进阶之路
开发语言·python·microsoft
chushiyunen38 分钟前
python中的异常处理
开发语言·python
观书喜夜长41 分钟前
大模型应用开发学习-基于 LangChain 框架实现的交互式问答脚本
python·学习