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

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

相关推荐
洋芋土豆5 分钟前
linux文件及目录管理和vim编辑
linux·vim
Geoking.14 分钟前
PyTorch 中 model.eval() 的使用与作用详解
人工智能·pytorch·python
nn在炼金15 分钟前
图模式分析:PyTorch Compile组件解析
人工智能·pytorch·python
执笔论英雄16 分钟前
【大模型训练】zero2 梯度分片
pytorch·python·深度学习
Danceful_YJ17 分钟前
25.样式迁移
人工智能·python·深度学习
烛阴21 分钟前
Python 几行代码,让你的照片秒变艺术素描画
前端·python
喆星时瑜22 分钟前
关于 ComfyUI 的 Windows 本地部署系统环境教程(详细讲解Windows 10/11、NVIDIA GPU、Python、PyTorch环境等)
python·cuda·comfyui
柳鲲鹏27 分钟前
RGB转换为NV12,查表式算法
linux·c语言·算法
程序猿(雷霆之王)31 分钟前
Linux——线程安全
linux·运维·服务器