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

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

相关推荐
CryptoRzz30 分钟前
股票数据源对接技术指南:印度尼西亚、印度、韩国
数据库·python·金融·数据分析·区块链
烦躁的大鼻嘎39 分钟前
【Linux】ELF与动静态库的“暗黑兵法”:程序是如何跑起来的?
linux·运维·服务器·c++·vscode·ubuntu
胖哥真不错1 小时前
Python实现NOA星雀优化算法优化卷积神经网络CNN回归模型项目实战
python·cnn·卷积神经网络·项目实战·cnn回归模型·noa星雀优化算法
qq21084629531 小时前
【Linux驱动】Linux 按键驱动开发指南
linux·驱动开发
L_cl1 小时前
【NLP 75、如何通过API调用智谱大模型】
linux·服务器·windows
努力学习的小廉1 小时前
深入了解linux系统—— 基础IO(下)
linux·运维·服务器
love530love2 小时前
【笔记】记一次PyCharm的问题反馈
ide·人工智能·windows·笔记·python·pycharm
梦醒沉醉2 小时前
MCP(一)——QuickStart
python·mcp
照物华2 小时前
httpx[http2] 和 httpx 的核心区别及使用场景如下
python·httpx
山海不说话2 小时前
PyGame游戏开发(入门知识+组件拆分+历史存档/回放+人机策略)
开发语言·python·pygame