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

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

相关推荐
默_笙9 小时前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
未济9 小时前
linux 配置环境变量
linux
傲世仙尊9 小时前
目录即文件-Ext文件系统收尾篇
linux·c语言
qq_426003969 小时前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫9 小时前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技10 小时前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
伞伞悦读10 小时前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时11 小时前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas
_艾伦 耶格尔.11 小时前
进程间通信
linux
Liuqy-0511 小时前
Linux IO编程——静态库、动态库
linux