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

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

相关推荐
垆边人似月.几秒前
预处理与参数调优(让识别率从“能看”到“可用”)
开发语言·python·自然语言处理
gf13211114 分钟前
python_高德地图驾车时长查询
数据库·python·mysql
镜子AI6 分钟前
镜子AI技术实践:用 Python 做 GEO 答案的实体提及抽取与归一化(零依赖两阶段方案)
python·ai
I Am a robert girl9 分钟前
从点到面:Superquadric 分解中“几何感知内点精修”的工程拆解
python·ransac·点云处理·三维感知·superquadric·几何基元拟合·内点判定
心随_风动12 分钟前
Ubuntu系统安装Apache服务教程
linux·ubuntu·apache
计算机毕业编程指导师13 分钟前
计算机毕设推荐:基于深度学习的动物图像识别方法研究(Python+Django+PyTorch)
pytorch·python·深度学习·计算机·毕业设计·课程设计·图像识别
Java后端的Ai之路14 分钟前
【AIAgent项目-AI生成PPT-09】灵活排版
前端·vue.js·人工智能·python·powerpoint
~~刘杨22 分钟前
用 Python 批量处理商品图:抠图、高清放大与图生视频(同步 API 完整示例)
图像处理·python·aigc
小小张说故事25 分钟前
Python 拼字符串为什么别在循环里用 +=?拆开 join 的两遍账:191.8 微秒与 6.8 微秒
python
CodeGL25 分钟前
15、Python 访问数据库
数据库·python