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

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

相关推荐
LOVE️YOU5 小时前
Python 中 Tuple 为什么有时可 Hash,有时不可 Hash?
开发语言·python·哈希算法
木卫二号Coding5 小时前
推荐Linux统计文件大小并操作删除工具-ncdu
linux·运维·服务器
小oo呆5 小时前
【学习心得】迭代器和可迭代对象
开发语言·python
AC赳赳老秦5 小时前
采集行为合规自检:OpenClaw 自动校验 robots 协议与采集频率,规避违规采集风险
java·开发语言·c++·python·php·deepseek·openclaw
迅猛龙办公室5 小时前
Python输出当前计算机的系统日期和时间
开发语言·前端·python
zhangrelay7 小时前
机械臂末端规划智能模型的误区演示
linux·笔记·学习·ubuntu·ros2
XiaoMaqqqq7 小时前
知名的IP驱动产业新场景新工具
网络·python·网络协议·tcp/ip
言乐67 小时前
Python实现语音审核模型
开发语言·python·django·virtualenv·pygame
程序员清风8 小时前
Python 数据分析环境搭建:从 Jupyter 到 pandas
python·jupyter·数据分析
月光船幽幽8 小时前
加性偏移外推提升参数识别可靠性
python·算法