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

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

相关推荐
happylifetree6 分钟前
Python34-35:核心语法-流程控制语句-循环-综合案例
python
吃饱了得干活21 分钟前
Agent 的记忆与工具:从上下文窗口到 MCP
python·agent·mcp
燐妤1 小时前
LangGraph-复习总览
python·ai·面试·agent·学习方法·langgraph
尹人入圣1 小时前
市面上IP驱动产业新场景新工具
运维·网络·python·tcp/ip
打工仔折腾 AI1 小时前
从BPE到SentencePiece:Transformer分词原理与Python实战对比
android·人工智能·python·深度学习·langchain·transformer·ai agent 实战
LRL_1 小时前
【实战指南】Node.js 跨平台依赖下载:如何在 Windows/Linux 环境下互跨下载目标系统的 npm/pnpm 包
linux·windows·node.js
骑着蜗牛撵大象3272 小时前
Qt 事件机制详解:从 QEvent 派生类到事件过滤器的全景指南
前端·python
高山有多高2 小时前
【Linux笔记】网络命令
linux
流形填表2 小时前
题库迁移实战:Excel中间格式与列映射
python·excel
东方芷兰2 小时前
Agent 技术摘要 06 —— Harness、原生视觉、Jev、mmproj、dsh
人工智能·笔记·python·ai·langchain·ai编程