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

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

相关推荐
小则又沐风a3 分钟前
深入理解TCP协议----滑动窗口,流量控制
linux·网络协议·tcp
Y幽谷客8 小时前
Python加载本地大模型(Qwen3.5 8B)
python·大模型
伞伞悦读8 小时前
【第36期】Python 目录与路径详解:pathlib、文件遍历、创建、复制、移动和删除风险
开发语言·python
线上放牧人9 小时前
Windows删除图标缓存
windows·python·pyqt
qq_5470261799 小时前
Python 变量和简单数据类型
python
bosins10 小时前
WSL2 启动即崩溃?调整超时参数解决 Docker 阻塞问题
linux·docker·wsl
web守墓人10 小时前
【goed/ui】自定义组件设计思想篇
linux·windows·ui·golang
智搜广告10 小时前
智搜广告:科技行业AI回答优化公司如何破局
大数据·python·elasticsearch·geo
kuroomi11 小时前
Ingress-Nginx与kubernetes 网络
linux·运维·网络·kubernetes
IpdataCloud11 小时前
AI智能体调用工具怎么核验来源IP?归属地、网络类型与代理风险识别(含Python代码)
数据库·python·tcp/ip