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 分钟前
Cortex-A7的运行模式
linux·arm开发
黄粱梦醒12 分钟前
UV快速搭建新项目
python
小学生-山海19 分钟前
【YOLO系列】基于YOLOv8/v11/v26与tkinter的车流量统计系统设计
python·yolo
zhangrelay22 分钟前
三分钟云课实践速通--C/C++程序设计--
linux·c语言·c++·笔记·学习·ubuntu
szial29 分钟前
Python Click 教程:从函数到专业命令行工具
开发语言·python
u01196082330 分钟前
ray 依赖分发
python
lbb 小魔仙39 分钟前
Ollama 本地部署大模型 + Python API 集成开发完整教程(2026最新版,含 GPU 加速配置)
开发语言·python
Max_uuc42 分钟前
【调度心法】别用 Mutex 制造“人质危机”!撕碎互斥锁的防御幻觉,论优先级反转与火星探测器的史诗级瘫痪
linux·运维·制造
孙同学_42 分钟前
【Linux篇】NTA机制与网络地址转换原理详解
linux·网络·智能路由器
小趴菜要进步1 小时前
Kali/Linux 更改国内镜像源
linux·运维·服务器