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

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

相关推荐
Zane1994几秒前
你以为的性能瓶颈,未必是真的瓶颈:用 cProfile 找到真凶
后端·python
小雪崩6 分钟前
嵌入式学习 day33:线程进阶
linux·c语言·学习
牢姐与蒯16 分钟前
Linux进程(四).进程优先级以及进程切换,进程调度
linux·运维·服务器·ubuntu
铁手飞鹰24 分钟前
VSCode Python .embed 嵌入式环境黄色波浪线问题
ide·vscode·python
大爱编程♡25 分钟前
Linux C 语言文件 IO 与构建工具实战指南
linux·服务器
辰辉创聚27 分钟前
重组蛋白表达不出来怎么办?蛋白表达失败、低表达及异常原因解析
python·oracle·eclipse·重组蛋白·蛋白·western blot
淼澄研学1 小时前
基于Docker与iptables的AI智能体网络隔离实操指南
开发语言·python
量化吞吐机1 小时前
程序员学量化开发,先用示例拆清结构
人工智能·python
Linux运维技术栈1 小时前
深度拆解 Linux logrotate 重复切割问题:根因、排查与生产级根治方案
linux·logrotate
ouynagda1 小时前
Linux多线程:互斥锁与信号量学习笔记
linux·笔记·学习