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

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

相关推荐
取经蜗牛43 分钟前
Python 第一阶段完全指南:从零到第一个实用工具
开发语言·python
创世宇图1 小时前
【Python工程化实战】OpenTelemetry 在 Python 中的全链路追踪落地:从埋点到可视化的完整实战指南
python·分布式链路追踪·性能监控·opentelemetry·微服务可观测性
风曦Kisaki1 小时前
#Linux数据库管理Day06:主从同步与MaxScale读写分离
linux·运维·数据库
小楼昨夜又东风1261 小时前
使用python快速拉包
linux
许彰午2 小时前
72_Python爬虫基础BeautifulSoup
爬虫·python·beautifulsoup
Tipriest_2 小时前
ubuntu创建和更换当前swap大小
linux·运维·ubuntu
zhanghongyi_cpp2 小时前
10. 实验书3.4.2 筛选达到预警阈值的病虫害数据
python
tuddy7894643 小时前
Codex++ 安全边界探秘:从模型能力到风险防御
人工智能·python·安全
C++、Java和Python的菜鸟3 小时前
第1章 集合高级
java·jvm·python
第六五3 小时前
Python 内置装饰器
开发语言·python