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

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

相关推荐
kobe_OKOK_3 小时前
__getattr__和__getattribute__如何用
python
全栈弄潮儿4 小时前
Python实战第2期: 变量与数据类型
后端·python·agent
长沙三为智能科技4 小时前
家政小程序门店运营模块设计:会员、下单、派单、结算四段链路的落地拆解
python·小程序·内容运营
Cc.Y4 小时前
Java零基础入门:可变字符串与包装类:StringBuilder、StringBuffer 与 通讯录管理系统实战
java·开发语言·python
启观川4 小时前
数据结构与算法 -第 3 章 常用算法-动态规划
数据结构·笔记·python·算法
程序员-Benothing4 小时前
Vim编辑器从入门到精通:模式、快捷键、配置、插件
linux·运维·服务器
码爸4 小时前
排序算法介绍
python·算法·排序算法
笔墨登场说说5 小时前
flink bin/start-cluster.sh 帮我做成开机启动
开发语言·python
‎ദ്ദിᵔ.˛.ᵔ₎5 小时前
linux 进程信号 (上)
linux·服务器
15Moonlight5 小时前
Linux网络(02):Socket 编程 UDP
linux·网络·udp