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

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

相关推荐
Bug退散师4 分钟前
多路IO复用[select版TCP服务器与poll版TCP服务器]与常用网络编程函数详解
linux·服务器·c语言·网络·驱动开发·tcp/ip
xiaoye-duck7 分钟前
《Linux系统编程》Linux 系统多线程(一):线程概念(从虚拟地址空间与分页机制到优缺点解析)
linux·线程
起予者汝也7 分钟前
Python 数据结构
开发语言·数据结构·python
LadenKiller8 分钟前
2026年量化工具增量,放回回测模拟实盘阶段判断
人工智能·python
石一峰69912 分钟前
驱动:私有数据为什么要在三个地方各挂一遍?
数据库·python·算法
国服第二切图仔13 分钟前
05-构建与特性开关
linux·服务器·ubuntu
FREEDOM_X13 分钟前
嵌入式——定时器工作原理
linux·c语言·单片机·嵌入式硬件·ubuntu
2601_9563198816 分钟前
最新量化软件怎么选,先按能力短板匹配工具类型
人工智能·python
Tbisnic30 分钟前
26.AI大模型:RNN、LSTM、GRU
人工智能·python·rnn·gru·大模型·llm·lstm
Thecozzy1 小时前
Skill和MCP和Subagent 的选择
linux·人工智能·ubuntu