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

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

相关推荐
笑锝没心没肺2 小时前
fail2ban工具安装配置及使用
linux·运维·服务器
聪明的一休丶2 小时前
VLLM v0.24.0 版本深度解析:新引擎、新架构与大规模服务全家桶升级
python·架构·vllm
万亿少女的梦1684 小时前
基于Python的高考志愿填报辅助系统设计与实现
java·spring boot·python·mysql·vue
大卡片4 小时前
linux内核驱动开发
linux·运维·驱动开发
心心喵5 小时前
[linux] nohup和pm2的区别 进程保活
linux·运维·服务器
闲猫5 小时前
Python FastAPI + SQLAlchemy 入门教程:从零搭建你的第一个 Web 应用
前端·python·fastapi
醉熏的石头6 小时前
Ubuntu 中的编程语言(中)
linux·ubuntu·scala
北极星日淘8 小时前
中古货品品相评级算法实战|Java权重计分实现标准化五级品相体系
开发语言·python
hangyuekejiGEO8 小时前
临沂GEO服务企业技术选型分析
人工智能·python
dddwjzx9 小时前
嵌入式Linux C应用编程入门——信号
linux·嵌入式