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

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

相关推荐
2601_9611940215 分钟前
27考研刘晓艳单词pdf
linux·sql·ubuntu·华为·pdf·.net
Warson_L1 小时前
class 扩展
python
前端与小赵2 小时前
Python 数据结构陷阱与复数运算优化:列表、元组、字典成员操作辨析及 NumPy 高效实践
python
2023自学中2 小时前
imx6ull 开发板 推流ov5640数据,虚拟机用 ffplay 拉流播放
linux·音视频·嵌入式·开发板
天天进步20152 小时前
Python全栈项目--基于深度学习的视频目标跟踪系统
python·深度学习·音视频
shandianchengzi2 小时前
【记录】Ghidra|Ubuntu 26.04 下 Ghidra 界面缩放完整指南
linux·ubuntu·逆向·ghidra
天天进步20152 小时前
Python全栈项目--Python自动化运维工具开发
运维·python·自动化
Soari2 小时前
Ubuntu 根分区文件系统损坏,系统启动时自动检查失败
linux·运维·ubuntu
(●—●)橘子……2 小时前
力扣第503场周赛练习理解
python·学习·算法·leetcode·职场和发展·周赛
杨云龙UP3 小时前
Oracle Health Check巡检脚本使用SOP V2.0:从HTML原始报告→生成Word专业巡检报告→交付客户_2026-06-03
linux·运维·数据库·sql·oracle·报告·巡检