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

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

相关推荐
脚踏实地,坚持不懈!7 分钟前
Android 上层卡顿在内核中的反应(基于 Linux v7.2.2)
android·linux·运维
AR-26710-8 分钟前
机器学习复习收官Day12
人工智能·python·机器学习·scikit-learn
xzal129 分钟前
Python之filter()和map()的区别(仅供学习参考)
笔记·python
H_oRIZoN_12 分钟前
Linux入门DAY36(TCP 并发服务器)
linux·服务器·tcp/ip
灵晔君18 分钟前
【Linux】基础IO(一)——文件、上层C库文件操作、底层linux原生IO
linux·运维·c语言
随遇而安zx24 分钟前
【地基篇】---JVM 类加载 源码解析(基于 Java 8)
java·jvm·python
Fcy64831 分钟前
Linux下 应⽤层⾃定义协议与序列化(JSON方法)
linux·json
koi77u1 小时前
嵌入式学习————————TCP并发服务器(1)
linux·学习
2601_962300471 小时前
Python TensorFlow对比PyTorch_Python TensorFlow和PyTorch在机器学习中的差异
pytorch·python·深度学习·机器学习·tensorflow
承渊政道3 小时前
【Python编程—从入门到实践】(Python条件判断完全入门:从布尔表达式到列表中的if实战)
开发语言·python·pycharm·条件判断·布尔表达式