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

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

相关推荐
Zane199412 小时前
类变量与实例变量:一个共享列表引发的线上事故
后端·python
Python私教13 小时前
一次性批准令牌:挡住旧授权误发新版本的工程设计
python·安全
for_ever_love__13 小时前
python基础语法学习: 数据容器
windows·python·学习
aiqianji13 小时前
文风接近真人的AI生成短篇小说软件有哪些?
人工智能·python
sxstj13 小时前
Ubuntu 完整安装并启用 Flatpak 教程
linux·运维·ubuntu
Sylvia33.14 小时前
从轮询到推送:足球数据API架构演进与火星数据技术拆解
java·服务器·网络·python·websocket·架构
瑞码空间14 小时前
Python爬虫进阶实战笔记
开发语言·python·计算机·python爬虫
天疆说14 小时前
Ubuntu 26.04 下 Intel Meteor Lake 核显 + NPU 驱动配置与 PyTorch NPU 推理实测
linux·pytorch·ubuntu
杨超越luckly14 小时前
Agent应用指南:获取12306官网全量站点及其编码信息
python·数据挖掘·数据分析·可视化·12306
mounter62514 小时前
突破单点限制:BPF 多跟踪点高效附加机制与新 ftrace 架构解析
linux·ebpf·linux kernel·kernel·ftrace