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 小时前
安装 Python 3.10+
开发语言·人工智能·python
梦想不只是梦与想2 小时前
Python 中的装饰器
python·装饰器
我叫唧唧波3 小时前
Python+AI 全栈学习笔记
人工智能·python·学习
bush43 小时前
嵌入式linux学习记录七,中断
linux·嵌入式
RisunJan3 小时前
Linux命令-nologin(用于系统账户或需要禁止交互式登录的场景)
linux·运维
copyer_xyf3 小时前
Python 异常处理
前端·后端·python
是阿建吖!3 小时前
【Linux】信号
android·linux·c语言·c++
城北徐宫3 小时前
Linux信号深度解剖:5种产生、3张表、4次切换
linux·c++·学习
倔强的石头1063 小时前
【Linux指南】Linux快捷键与系统实用技巧
linux·运维·服务器
番茄地瓜4 小时前
Linux 配置静态 IP 步骤
linux·运维·服务器