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")

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

相关推荐
小白快快跑哦7 分钟前
python-字符串全解(六):正则表达式-前后相断言
开发语言·python·正则表达式·前后相断言
kimnoic12 分钟前
Python数据分析中正则表达式匹配字符串与常用函数示例详解
开发语言·python
程序员梅雨19 分钟前
ZooKeeper面经总结
java·大数据·linux·分布式·后端·zookeeper·中间件
许墨の小蝴蝶22 分钟前
Pillow 替换图片文字后字号偏小的排查
python·pillow
lingran__23 分钟前
Linux进程万字详解(二)|进程状态深度剖析:调度队列、内核链表、D状态设计哲学、僵尸孤儿进程与Slab机制
linux·进程管理·内核链表·pcb·僵尸进程·孤儿进程·进程状态
朝朝辞暮i31 分钟前
第 01 讲:Python 变量、对象、数据类型与内存引用
开发语言·python
外收内放1 小时前
Python基础语法练习题(69)
开发语言·python
TomEval1 小时前
【测AI】第11篇:深度学习基础 —— 神经网络是怎么工作的
人工智能·python·深度学习·神经网络·机器学习·aigc
zhang-ge1 小时前
python包和项目管理器uv在ubuntu下的安装与使用
开发语言·python·uv
for_ever_love__1 小时前
LangChain 降级、重试与超时:让服务在模型抽风时还能用
python·自然语言处理·langchain·agent·超时·重试·with_retry