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

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

相关推荐
仙女修炼史11 分钟前
gradcam在yolo中的应用
人工智能·python·yolo
xie0510_42 分钟前
TCP socket
linux·网络协议·tcp/ip
aningx1 小时前
# EasyTier 开机自启动部署教程
linux
李可以量化1 小时前
Redis Client 从了解到精通(六):redis-py 服务控制与状态监控辅助函数详解
python
DeeplyMind1 小时前
Linux 内核模块加载路径与 initramfs 生效机制分析
linux·initramfs·depmod·modprobe
李可以量化1 小时前
Redis Client 从了解到精通(六)下:redis-py 时间、库管理与持久化辅助函数详解
python
晓窗科技1 小时前
AI基座哪家好
大数据·人工智能·python
麻雀飞吧1 小时前
学量化:看到“近期工具推荐”时,先问工具要解决什么问题
人工智能·python
jayson.h1 小时前
python——pdf编辑
前端·python·pdf
聪明蛋子哟1 小时前
多智能体协作的三种模式:从群聊到分层,如何设计可扩展的Agent系统
后端·python·flask