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

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

相关推荐
xufengzhu6 分钟前
Python库PyMySQL的使用指南
开发语言·python·pip
人间乄惊鸿客7 小时前
Linux所遇问题自记录
linux
AOwhisky8 小时前
MySQL 学习笔记(第四期):SQL 语言之多表查询
linux·运维·网络·数据库·笔记·学习·mysql
Phantom Void8 小时前
服务器处理客户端请求的设计方法
linux·运维·网络
一段路8 小时前
【虚拟机】Linux常用命令
linux·vim
世辰辰辰8 小时前
批量修改图片/文本名子
开发语言·python·批量修改文件名
daad7779 小时前
继续记录无人机SITL的起飞
linux
剑神一笑10 小时前
Linux ls 命令深度解析:从目录遍历到颜色输出的实现原理
linux·服务器·数据库
myenjoy_110 小时前
MQTT 与 Sparkplug B——从车间到云端的最后一公里
网络·python
颜酱11 小时前
LangChain 输出解析器:把模型回复变成你要的数据
python·langchain