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

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

相关推荐
pride.li2 分钟前
第12章 Python 教程-流程控制:循环结构
linux·服务器·python·算法
迷途之人不知返7 分钟前
【基础IO】-5-简单理解三个标准流——stdin、stdout、stderr
linux
牛马鸡niumasi8 分钟前
【Linux】进程退出
linux
鬼手点金21 分钟前
模型即 Agent:当模型本身成为产品
开发语言·前端·人工智能·python·机器学习
田里的水稻26 分钟前
PyTorch-Dataset\DataLoader数据加载
人工智能·pytorch·python
卷无止境32 分钟前
Python 3.14 自由线程:拆掉 GIL 之后,我们到底得到了什么
后端·python
染指111034 分钟前
147.Agent-LangGraph归并函数
开发语言·人工智能·python·langchain·agents
小白学大数据1 小时前
逆向分析短视频平台 a_bogus 参数:从 JavaScript 混淆到 Python 复现
javascript·python·音视频
外收内放1 小时前
数据分析(数据清洗)
python·学习·数据分析
小小张说故事1 小时前
Python 的 True + True 为什么等于 2?bool 是 int 子类,这个设计坑了多少人
python