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

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

相关推荐
努力学习的小廉7 分钟前
深入了解linux系统—— POSIX信号量
linux·运维·服务器
刘一说11 分钟前
CentOS部署ELK Stack完整指南
linux·elk·centos
从零开始的ops生活18 分钟前
【Day 50 】Linux-nginx反向代理与负载均衡
linux·nginx
IT成长日记28 分钟前
【Linux基础】Linux系统配置IP详解:从入门到精通
linux·运维·tcp/ip·ip地址配置
夜无霄32 分钟前
安卓逆向(一)Ubuntu环境配置
linux·运维·爬虫·ubuntu
田野里的雨35 分钟前
manticore离线安装(Ubuntu )
linux·运维·服务器·全文检索
精灵vector44 分钟前
LLMCompiler:基于LangGraph的并行化Agent架构高效实现
人工智能·python·langchain
Angletank1 小时前
虚拟机中centos简单配置
linux·经验分享·程序人生·centos
黑唐僧1 小时前
Linux 高阶命令-常用命令详解
linux