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

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

相关推荐
江屿风3 小时前
【Linux系统】【Linux进程终止等待详解与程序替换机制初体验】流食般投喂
linux·运维·笔记·系统架构·centos·unix
螺蛳粉 螺蛳粉3 小时前
CentOS 7.9 自建 Yum 源服务器搭建指南
linux·服务器·centos
程序员yu4 小时前
数智码力:Python作用域完全梳理,全局变量局部变量不再混乱
开发语言·python·学习
北城笑笑4 小时前
Python Dev 02 & Tkinter webbrowser 实战,手写第一个 Python 桌面 GUI 小工具
人工智能·python·pip
CTA量化套保4 小时前
搜索“2026年交易工具推荐”时,先问清它要解决什么问题
人工智能·python
Ticnix4 小时前
答案一个字一个字往外蹦,聊天记录却一条都没存下来
python·agent
Ticnix4 小时前
"多数新闻站都禁止内嵌"——这句话我信了很久,直到测了 16 个站点
python·agent
吴声子夜歌4 小时前
Shell编程实例——脚本编程的附加特性
linux·运维·shell
yunwei374 小时前
eBPF 教程:BPF 调度器入门
linux·后端·性能优化
贝猫说python4 小时前
阿里云部署qwen 、第5步:阿里云服务器上大模型运行demo.py,固定提示词模板 拼接用户输入,输出符合要求格式结果
python