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

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

相关推荐
ltl5 小时前
大多数「无锁」代码其实不是无锁的
linux
ltl5 小时前
Linux 内核的内存屏障:一个让我调了三天的 bug
linux
天才测试猿5 小时前
2026软件测试面试八股文(含答案+文档)
自动化测试·软件测试·python·功能测试·测试工具·面试·职场和发展
张小凡vip6 小时前
python--爬虫--成熟的爬虫框架Scrapy
爬虫·python·scrapy
Pluchon6 小时前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
Lonely 净土7 小时前
Rocky Linux 安装教程
linux·运维·服务器
不瘦80斤不改名7 小时前
01-vibe-coding-起源与本质
人工智能·python
夜雪一千7 小时前
如何对新闻数据进行模糊去重
python
oyguyteggytrrwwwrt9 小时前
3dgs渲染部分详细注释
python
李白你好11 小时前
Windows 离线 Linux 提权辅助查询工具
linux