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

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

相关推荐
Str_Null8 分钟前
杀戮尖塔通过修改记录文件和备份文件进行修改血量和金币
python
钝挫力PROGRAMER11 分钟前
复杂PDF转Markdown实战:从Marker到多模态的处理全记录
python·pdf
Irene199115 分钟前
Linux 中换行符 = 命令结束,xargs 防止意外执行的机制,不支持标准输入的命令,-i 在各个命令中的真实含义
linux
TechWayfarer17 分钟前
账号安全实战:基于IP归属地基线的三原则异地登录风控模型
服务器·网络·python·安全·网络安全
Edward1111111121 分钟前
SSL/TSL配置 集群节点间通信加密还有客户端
linux·服务器·ssl
dhashdoia34 分钟前
2026年GPT-5.5与GPT-Image-2深度解析:国内部署指南
人工智能·python·gpt·ai作画·gpt国内部署
Codigger官方38 分钟前
Ubuntu 与 Fedora:两大 Linux 发行版怎么选?
linux·运维·ubuntu
jayson.h40 分钟前
正则表达式:从文件名提取器件编号
开发语言·python·正则表达式
2601_953660371 小时前
Java Map集合详解与实战
java·开发语言·python
程序员老舅1 小时前
Linux:谁把根目录卸载了?
linux·c++·容器·linux内核·文件系统·根目录