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

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

相关推荐
AndrewHZ4 分钟前
【图像处理基石】暗光增强算法入门:从原理到实战(Python+OpenCV)
图像处理·python·opencv·算法·计算机视觉·cv·暗光增强
月墨江山16 分钟前
Ubuntu 20.04 使用 Issac Gym 进行宇树G1人形机器人进行强化学习训练(Linux仿真)
linux·ubuntu·机器人
纪伊路上盛名在1 小时前
python5.1 数据类dataclass
python·面向对象编程·oop
用户718841750781 小时前
深究 Python 中 int () 函数为何无法转换含小数点的字符串
python
on_pluto_1 小时前
LLaMA: Open and Efficient Foundation Language Models 论文阅读
python·机器学习
小二·1 小时前
mac下解压jar包
ide·python·pycharm
XXX-X-XXJ1 小时前
二:RAG 的 “语义密码”:向量、嵌入模型与 Milvus 向量数据库实操
人工智能·git·后端·python·django·milvus
天朝八阿哥2 小时前
关于xfce4-pulseaudio-plugin中文翻译的bug
linux·debian
z202305082 小时前
linux之 remoteproc 内核实现源码分析
linux·运维·服务器
阿方索2 小时前
shell脚本
linux·运维