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

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

相关推荐
小大宇12 小时前
python milvus 案例
开发语言·python·milvus
2601_9657984713 小时前
How to Build a Custom Artisan Store on WordPress: Crafti Theme Review
linux·服务器·数据库
mounter62513 小时前
深度解析 Linux 内核中的 iomap 子系统:历史、演进、核心机制与未来
linux·文件系统·linux kernel·kernel·iomap
BerryS3N13 小时前
Java 后端转型大模型:Demo 能跑不等于能上线
java·人工智能·python·java后端·spring ai·langchain4j·大模型转型
制造数据与AI践行者老蒋13 小时前
智联工坊实战:从“金鱼记忆”到“记住了”:给制造Agent装上记忆芯片的完整指南
人工智能·python·langchain·制造
某林21213 小时前
ros从底层硬件到 Web 端部署
python·机器人·硬件架构·ros2
FBI HackerHarry浩14 小时前
AI大模型开发V2第四阶段机器学习概述
人工智能·python·机器学习
养海绵宝宝的小蜗14 小时前
LVS(Linux Virtual Server)项目知识点总结
linux·运维·lvs
axinawang14 小时前
第22课 石头剪刀布
python
测试秃头怪14 小时前
postman接口测试详解
自动化测试·软件测试·python·测试工具·测试用例·接口测试·postman