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

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

相关推荐
迎風吹頭髮21 分钟前
Linux内核架构浅谈60-Linux块设备驱动:请求队列与BIO结构的交互流程
linux·运维·交互
☆璇26 分钟前
【Linux】Socket编程TCP
linux·服务器·tcp/ip
wifi chicken1 小时前
Linux 网络协议栈数据流跟踪-静态路由demo
linux·网络协议栈·静态路由
程序员爱钓鱼1 小时前
Python编程实战 · 基础入门篇 | 类型转换与输入输出
后端·python
程序员爱钓鱼1 小时前
Python编程实战 · 基础入门篇 | 运算符详解
后端·python·编程语言
程序员的世界你不懂1 小时前
【Linux】Centos替代方案
linux
潜心编码1 小时前
基于Flask的志愿者管理系统
后端·python·flask
剑小麟1 小时前
windows系统安装wls/Ubuntu子系统教程
linux·运维·ubuntu
Ronin3052 小时前
【Linux网络】应用层自定义协议
linux·网络·应用层·序列化
开心-开心急了2 小时前
Flask入门教程——李辉 第四章 静态文件 关键知识梳理 更新1次
后端·python·flask