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

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

相关推荐
juesdo15 小时前
vulnos OS-00118靶场通关
linux·web安全·网络安全·docker
叠层归一研究院16 小时前
如何用程序搭建一个 AGI 种子系统(三):生长如何对接物理与数学宇宙
人工智能·python·算法·机器学习·transformer·agi
霸刀16 小时前
nslookup 与 dig 使用指南:DNS 查询、区别对比及真实案例解读
linux·cdn·dns
郝亚军16 小时前
asqlite-autoconf-3310100 的ubuntu 22.04 aarch64交叉编译
linux·运维·ubuntu
jufeng130716 小时前
【系列:手搓自主 AI Agent:Hermes 架构原理剖析 · 第 5 篇】
python·ai agent·上下文压缩
AndrewHZ16 小时前
图像处理入门008 | 阶段总结:环境测试与基础概念测验
图像处理·python·opencv·计算机视觉·cv
北斗落凡尘16 小时前
LangGraph 入门实战(10)--时光回溯
python·langchain
今天AI了吗16 小时前
Agent & AI 名词大扫盲
数据库·人工智能·python·sql·rust
笑锝没心没肺16 小时前
Linux安装docker及运行容器测试
linux·运维·docker
张张123y16 小时前
Hermes Agent 是什么?它能做什么,以及如何部署到飞书
人工智能·python·飞书