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

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

相关推荐
wa的一声哭了几秒前
矩阵分析 单元函数矩阵微积分和多元向量值的导数
linux·c语言·c++·线性代数·算法·矩阵·云计算
老歌老听老掉牙几秒前
SymPy 中矩阵乘法的顺序与元素类型分析
python·矩阵·sympy
陈葛杰9 分钟前
VMware 安装 Rocky Linux 9.6(Minimal 版)超详细图文教程|轻量 · 安全 · 生产级
linux·运维·服务器
时间之里24 分钟前
【linux】:目录解析
linux·运维·服务器
bosins30 分钟前
基于Python实现PDF文件个人隐私信息检查
开发语言·python·pdf
bosins30 分钟前
基于Python开发PDF文件元数据查看器
开发语言·python·pdf
小北方城市网37 分钟前
第 10 课:Python 全体系实战整合与职业进阶指南(完结篇)
大数据·开发语言·数据库·python
WXG101138 分钟前
【Flask-10】modbus tcp通信
python·tcp/ip·flask
540_54039 分钟前
ADVANCE Day31
人工智能·python·机器学习
The star"'44 分钟前
Python
开发语言·python·pygame