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

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

相关推荐
Victoria.a几秒前
python基础语法
开发语言·python
彭泽布衣24 分钟前
Linux异常文件名文件如何删除
linux·运维·服务器
优泽云安全24 分钟前
如何选择IRCS云信息安全管理系统 IRCS云资源评测
linux·服务器·安全·安全架构
ShineWinsu25 分钟前
对于Linux:Ext系列文件系统的解析—下
linux·面试·笔试·文件系统··ext2·挂载分区
小夏子_riotous26 分钟前
Docker学习路径——2、安装
linux·运维·分布式·学习·docker·容器·云计算
xiaotao13139 分钟前
01-编程基础与数学基石: Python核心数据结构完全指南
数据结构·人工智能·windows·python
青苔猿猿40 分钟前
【1】JupyterLab安装
python·jupyter
xiaoyaohou1141 分钟前
023、数据增强改进(二):自适应数据增强与AutoAugment策略
开发语言·python
添砖java‘’42 分钟前
NAT代理、内网打洞和内网穿透
linux·服务器·网络
鬼圣42 分钟前
Python 上下文管理器
开发语言·python