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

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

相关推荐
code bean4 分钟前
Flask图片服务在不同网络接口下的路径解析问题及解决方案
后端·python·flask
Chasing Aurora23 分钟前
Python后端开发之旅(三)
开发语言·python·langchain·protobuf
萧曵 丶41 分钟前
Linux 业务场景常用命令详解
linux·运维·服务器
豆是浪个1 小时前
Linux(Centos 7.6)命令详解:ps
linux·windows·centos
于越海2 小时前
材料电子理论核心四个基本模型的python编程学习
开发语言·笔记·python·学习·学习方法
Run_Teenage2 小时前
Linux:深刻理解缓冲区
linux
中年程序员一枚2 小时前
Springboot报错Template not found For name “java/lang/Object_toString.sql
java·spring boot·python
youxiao_902 小时前
kubernetes 概念与安装(一)
linux·运维·服务器
凡梦千华2 小时前
logrotate日志切割
linux·运维·服务器
wdfk_prog2 小时前
[Linux]学习笔记系列 -- [fs][proc]
linux·笔记·学习