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

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

相关推荐
swordbob6 小时前
NIO 的 Channel 里有多个 BIO 吗?
linux·网络·nio
Fcy6486 小时前
Linux下 信号的保存与捕捉
linux·中断·信号的捕捉·信号的保存
JOJO数据科学6 小时前
JupyterLab Electron 鸿蒙 PC 适配全记录:从 Python 原生崩溃到 node-static 本地工作台
python·electron·harmonyos
xufengzhu6 小时前
第三方 Python 库 redis-py + hiredis 的使用
开发语言·redis·python
llxxyy卢7 小时前
polar夏季赛部分题目
开发语言·python
闵孚龙7 小时前
PyTorch 系列 之 nn.Module:所有模型的骨架
人工智能·pytorch·python
AI玫瑰助手7 小时前
Python模块:from...import...导入指定内容
开发语言·python·信息可视化
A_humble_scholar7 小时前
Linux(九) 进程管理完全指南:从入门到实战
linux·运维·chrome
小森林之主7 小时前
Python re 模块速查:从实战对比中掌握正则表达式
python·正则表达式·性能测试·re模块·编程实战
江华森7 小时前
Linux 操作命令完全指南
linux·运维