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

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

相关推荐
互亿无线明明15 小时前
国际短信通知服务:如何为全球业务构建稳定的跨国消息触达体系?
java·c语言·python·php·objective-c·ruby·composer
深盾科技15 小时前
Linux跨进程内存操作的3种方法及防护方案
java·linux·网络
HalvmånEver15 小时前
Linux:基础IO(一)
linux·运维·服务器
Lynnxiaowen15 小时前
今天我们学习kubernetes内容持久化存储
linux·运维·学习·容器·kubernetes
Starry_hello world15 小时前
Linux 信号
linux
KingRumn15 小时前
Linux进程间通信之消息队列
linux·服务器·网络
jerryinwuhan15 小时前
1210_linux_2
linux·运维·服务器
IDC02_FEIYA15 小时前
Linux怎么看服务器状态?Linux查看服务器状态命令
linux·运维·服务器
相思半15 小时前
数据偏见去偏方法系统方法论学习(基础知识+实践运用)-新手友好版
大数据·人工智能·python·深度学习·机器学习·数据分析
爱潜水的小L15 小时前
自学嵌入式day28,文件操作
linux·数据结构·算法