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

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

相关推荐
金銀銅鐵3 小时前
[Python] 基于欧几里得算法,实现分数约分计算器
python·数学
tntxia4 小时前
linux curl命令详解_curl详解
linux
Lyn_Li5 小时前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现
python·kaggle·比赛复盘·金融预测
扛枪的书生7 小时前
Linux 网络管理器用法速查
linux
小九九的爸爸9 小时前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
顺风尿一寸10 小时前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
阿耶同学10 小时前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
XIAOHEZIcode16 小时前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫18 小时前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
花酒锄作田1 天前
Pydantic校验配置文件
python