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

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

相关推荐
吴佳浩30 分钟前
LangChain 深入
人工智能·python·langchain
网安-轩逸3 小时前
回归测试原则:确保软件质量的基石
自动化测试·软件测试·python
Mr_Xuhhh3 小时前
YAML相关
开发语言·python
阿巴~阿巴~3 小时前
JsonCpp:C++ JSON处理利器
linux·网络·c++·json·tcp·序列化和反序列化
咖啡の猫3 小时前
Python中的变量与数据类型
开发语言·python
ao_lang3 小时前
数据链路层
linux·服务器·网络
汤姆yu4 小时前
基于springboot的电子政务服务管理系统
开发语言·python
z***3354 小时前
【MySQL系列文章】Linux环境下安装部署MySQL
linux·mysql·adb
执笔论英雄4 小时前
【RL】python协程
java·网络·人工智能·python·设计模式
偶像你挑的噻4 小时前
13-Linux驱动开发-中断子系统
linux·驱动开发·stm32·嵌入式硬件