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

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

相关推荐
Tanner_SL18 分钟前
Linux笔记之vim操作
linux·vim
阿图灵22 分钟前
OpenCV 算术运算四件套:NOT/AND/OR 位运算与图像混合
图像处理·人工智能·python·opencv·计算机视觉·位运算
边吃番茄边敲代码26 分钟前
企业智能助手Agent 安全测试,包含Prompt Injection 和越权工具调用
人工智能·python·功能测试·ai·单元测试·prompt·模块测试
用户0413284651332 分钟前
Linux 查看端口占用的 6 种方法:ss、netstat、lsof 实战
linux
阿图灵36 分钟前
OpenCV 阈值与模糊:全局/自适应阈值、Canny 边缘检测与三种模糊
图像处理·人工智能·python·opencv·计算机视觉·边缘检测
二宝哥37 分钟前
Rocky Linux 10.2 安装 PostgreSQL 15 完整教程
linux·运维·postgresql
不会就选b38 分钟前
Linux之线程池(二)
linux·运维·服务器
M78佐菲41 分钟前
Linux学习笔记:进程回收、exec函数簇与线程
linux·笔记·学习·算法
OpenFDE开源桌面42 分钟前
实操:如何将安卓 App与Linux系统应用级融合(附代码)
android·linux
桃西西呀1 小时前
国内金价破 1000,「涨了多少」和「该买多少」是数学问题
人工智能·python·数据分析