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

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

相关推荐
“愿你如星辰如月”29 分钟前
Linux:进程间通信
linux·运维·服务器·c++·操作系统
云和数据.ChenGuang43 分钟前
pycharm怎么将背景换成白色
ide·python·pycharm
我的xiaodoujiao1 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 25--数据驱动--参数化处理 Excel 文件 2
前端·python·学习·测试工具·ui·pytest
DO_Community1 小时前
基于AI Agent模板:快速生成 SQL 测试数据
人工智能·python·sql·ai·llm·ai编程
Code Warrior3 小时前
【Linux】应用层协议HTTP
linux·网络·网络协议·http
Q_Q5110082853 小时前
python+django/flask的宠物用品系统vue
spring boot·python·django·flask·node.js·php
Hello,C++!3 小时前
linux下libcurl的https简单例子
linux·数据库·https
hmbbcsm3 小时前
练习python题目小记(五)
开发语言·python
蓝桉~MLGT3 小时前
Python学习历程——文件
python·学习·策略模式