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

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

相关推荐
IvanCodes12 小时前
Python 基础语法(六):字典与集合
python
lie..13 小时前
30天从零开始学AI应用开发(Day 4):Python 极速入门(上):够用就行,别啃书
人工智能·python·大模型
正经教主13 小时前
【FDE系列】阶段2:Day 38:Shell 脚本 — 把命令串起来自动跑
人工智能·python·fde
诺伦13 小时前
多Agent架构下Token成本优化实战:Agent编排策略与预算控制全解析
python·ai agent·token优化·agent编排·多agent架构·llm成本控制
蓝胖的四次元口袋13 小时前
Python函数与面向对象
python
临期冰淇淋13 小时前
Unisoc 展锐平台Camera摄像头分辨率适配
linux·c语言·驱动开发
钱栈up13 小时前
番茄小说榜单爬虫失效排查:从页面路由变更到API参数映射的全流程复盘配置「项目记忆」后,德州扑克项目开发效率提升40%
python
学电子她就能回来吗13 小时前
把自然语言变成可制造 CAD:开源 SolidWorks Automation Skill 的工程化实践
人工智能·python·自动化·solidworks·mcp
流浪00113 小时前
Linux系统篇36——线程(一) 线程的概念、本质和Linux的实现方式
linux·面试·操作系统·线程
长沙三为智能科技14 小时前
中小企业数据驱动决策:从老板拍脑袋到数据说话的4步实操
python