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

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

相关推荐
陈天伟教授14 小时前
人工智能训练师认证教程(2)Python os入门教程
前端·数据库·python
2301_7644413314 小时前
Aella Science Dataset Explorer 部署教程笔记
笔记·python·全文检索
爱笑的眼睛1114 小时前
GraphQL:从数据查询到应用架构的范式演进
java·人工智能·python·ai
BoBoZz1914 小时前
ExtractSelection 选择和提取数据集中的特定点,以及如何反转该选择
python·vtk·图形渲染·图形处理
liwulin050614 小时前
【PYTHON-YOLOV8N】如何自定义数据集
开发语言·python·yolo
木头左15 小时前
LSTM量化交易策略中时间序列预测的关键输入参数分析与Python实现
人工智能·python·lstm
电子硬件笔记15 小时前
Python语言编程导论第七章 数据结构
开发语言·数据结构·python
南棱笑笑生15 小时前
20251217给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-5.10】后调通ov5645【只能预览】
linux·c语言·开发语言·rockchip
HyperAI超神经16 小时前
【vLLM 学习】Prithvi Geospatial Mae
人工智能·python·深度学习·学习·大语言模型·gpu·vllm
逻极16 小时前
Python MySQL防SQL注入实战:从字符串拼接的坑到参数化查询的救赎
python·mysql·安全·sql注入