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

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

相关推荐
程序员小远13 分钟前
接口测试之文件上传
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
ICECREAM15 分钟前
I/O 多路复用完全指南 —— select、poll、epoll
linux
进阶的猪31 分钟前
Linux 内核移植过程学习
linux·学习
江华森35 分钟前
Python 实现高德地图找房(三):地图可视化与高德 JS API
开发语言·javascript·python
曲幽1 小时前
Anki插件开发必知必会:钩子函数与右键菜单定制
python·fastapi·anki·menu·browser·addons
技术工小李1 小时前
现场评分系统|景泰2026“农创客”杯大赛实战应用宣传
python
nanawinona2 小时前
2026年AI量化学习,交易认知和技术实现要一起走
人工智能·python
问简2 小时前
【共享盘】ubuntu、windows
linux·windows·ubuntu
小生不才yz3 小时前
Shell脚本精读 · S13-01 | POSIX sh 与 Bash:语法对照表
linux
Csvn3 小时前
Python 开发技巧 · 生成器(Generator)进阶 —— 从 yield 到 yield from,写出省内存的生产者-消费者模式
后端·python