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

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

相关推荐
lolo大魔王4 小时前
Linux列出文件和目录
linux·运维·服务器
zadyd4 小时前
vLLM Linux 双卡部署大模型服务器指南
linux·人工智能·python·机器学习·vllm
j_xxx404_4 小时前
Linux命名管道:跨进程通信实战指南|附源码
linux·运维·服务器·人工智能·ai
楼田莉子4 小时前
仿Muduo的高并发服务器:Http协议模块
linux·服务器·c++·后端·学习
紫小米10 小时前
后端日志管理
python·fastapi
milo.qu11 小时前
RockyLinux9.7 docker部署Jisti Meet
linux·docker·容器
GanGanGanGan_11 小时前
CentOS 7.9 glibc 2.17 源码编译升级到 glibc 2.31
linux·运维·centos·glibc
charlie11451419111 小时前
嵌入式Linux驱动开发——class 和 device 模型 - 自动创建设备节点的幕后机制
linux·运维·驱动开发
白雪茫茫11 小时前
监督学习、半监督学习、无监督学习算法详解
python·学习·算法·ai
つ安静与叛逆的小籹人12 小时前
小红书API:通过笔记ID获取笔记详情数据教程
笔记·python