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

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

相关推荐
2401_868534783 小时前
指令集-最常用 Linux 命令速查手册(整合版)
linux·网络协议
青 春 记 忆3 小时前
零基础入门python30:Flask个人账本从空目录运行与阶段验收
python·flask·后端开发
ltl3 小时前
小文件问题:文件数量如何放大元数据与 I/O 成本
linux
ltl4 小时前
网络延迟优化:Nagle、TCP_NODELAY 与中断亲和
linux
l1258654 小时前
# LangGraph Memory机制深度解析:短期记忆与长期记忆的工程实践
前端·人工智能·python·langchain·bootstrap
张文君4 小时前
ubuntu26.04从ext4改成mdadm的raid1+lvm启动
linux·运维·网络
xx~t4 小时前
嵌入式——进程与线程1
linux·c语言·学习·嵌入式·进程与线程
DevHub4 小时前
QEMU + Busybox 搭建嵌入式 Linux 开发环境:内核编译到启动,30 秒一个迭代
linux·运维·服务器
ouynagda4 小时前
Linux 进程管理详解:从概念到实践
linux·运维·网络