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

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

相关推荐
留白_1 分钟前
pandas练习题
python·数据分析·pandas
睡一觉就好了。6 分钟前
make基础
linux
码界索隆9 分钟前
Python转Java系列:面向对象基础
java·开发语言·python
睡一觉就好了。9 分钟前
gcc/g++
linux
逻辑星辰13 分钟前
x-ds-pow-response逆向分析
开发语言·人工智能·python·深度学习·算法
Championship.23.2415 分钟前
Linux 3.0 串口机制深度解析:传统8250驱动与基础RS-232/485支持
linux·运维·服务器
c_lb728826 分钟前
涨跌停与流动性变差还要不要挂单:quote 涨跌停字段与熔断思路
python·区块链
顾喵29 分钟前
VME总线详解:原理、架构、时序、协议、迭代、调试与实战应用
linux·网络协议
非生而知之者30 分钟前
基于灰狼算法优化的电量预测
python·算法·群体智能算法·电力预测