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

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

相关推荐
CHEEVEN_QY3 小时前
搅拌摩擦焊FSW工艺参数对焊缝成形影响的实验研究10.1
linux·服务器·数据库
10年前端老司机3 小时前
实战分享:基于 PyMuPDF+Qwen-VL 实现图文兼容的 PDF RAG 方案
人工智能·python·agent
2601_962885723 小时前
如何用 Python 回测定投策略(定期定额 DCA)?(和一次性买入对比)
开发语言·人工智能·python
蜗牛互联网3 小时前
Python接入Gemini 3.8 Flash实现票据视觉抽取与规则校验
java·javascript·网络·人工智能·python
小小张说故事3 小时前
Python 虚拟环境到底怎么选?venv/conda/pipenv/poetry 一张对比表 + 9 个踩坑
python
H.莓飛3 小时前
【数据结构】链表_OJ题
linux·数据结构·算法·链表
在世修行3 小时前
干货:配置持久化与引擎状态的可视化
python·可视化·持久化
虎大猫猫3 小时前
Python教程——按位取反的原理
开发语言·python
木白CPP4 小时前
USB(一): USB 概述&&介绍
linux·网络·嵌入式硬件
熬夜敲代码的猫4 小时前
Linux:进程概念
linux