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

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

相关推荐
春涧草茶12 分钟前
慢就是快-11-1数据容器 | 列表
python
维克兜率天16 分钟前
【维克】技术指标是什么:从均线到MACD的数学原理
人工智能·笔记·python·算法·量化
卷无止境23 分钟前
当FastAPI遇上机器学习,一个脚手架工具能省下多少工夫
后端·python·fastapi
卷无止境31 分钟前
Kilo CLI 到底是什么
人工智能·后端·python
智购科技无人售货机厂家39 分钟前
2026自动售货机出货口防夹手设计:从红外检测到电机反转的工程实践~YH
大数据·linux·单片机·嵌入式硬件·微信
新时代牛马1 小时前
异常向量与VBAR_ELx:Linux entry.S 中的vectors 布局
linux·运维·服务器
H_oRIZoN_1 小时前
Linux入门DAY32(文件 IO、进程、线程、IPC 通信)
linux·运维·服务器
0+1111 小时前
Linux --Ext系列文件系统
linux·运维·服务器
SurpriseDPD1 小时前
bpftrace‑tasks 工具代码分析
开发语言·python
BS30813_vx2 小时前
【编号:01652】Spring Boot村务管理系统:财务公开、党建活动与计生服务一体化实战
开发语言·python