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

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

相关推荐
Thomas.Sir6 分钟前
第38课:TensorFlow|可视化工具TensorBoard全用法【日志写入、指标监控、网络可视化】
人工智能·python·tensorflow
LongRunning8 分钟前
【linux】RK3568(五)云服务器-视频推流
linux
SEO_juper16 分钟前
外贸多语言站最隐蔽的流量杀手:hreflang 错了,谷歌把德语页推给美国人(附审计脚本)
开发语言·前端·python·seo·独立站·谷歌优化
赵民勇22 分钟前
resolvectl命令详解
linux·运维
新时代牛马28 分钟前
Linux 日志管理:journald、rsyslog 与 logrotate
linux·运维·服务器
Metaphor69229 分钟前
快速合并 Word 文档【Python 指南】
python·word
资深电气设计39 分钟前
技术解析:ABB变频器ACH580/ACS180在CDU循环泵系统的应用技术框架
linux·运维·服务器
自律最差的编程狗44 分钟前
Ubuntu下Docker部署Ollama 轻量模型
linux·ubuntu·docker
新时代牛马1 小时前
Linux 网络配置:iproute2、DNS 与连通性排障
linux·服务器·网络
JAVA老架构AI智能化1 小时前
如何高质量分块
人工智能·python