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

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

相关推荐
funnycoffee12313 小时前
Cisco ip access-list序号重排方法
linux·网络·tcp/ip
IsSh9nj6q13 小时前
Python全栈应用搭建神器magic-dash .新版本介绍
开发语言·python·dash
殷忆枫13 小时前
Linux 4G模块驱动适配实战:从手动绑定到自动识别
linux·运维·服务器
Cachel wood13 小时前
hands-on-modern-rl:动手学强化学习策略梯度reinforce
开发语言·python
☆凡尘清心☆14 小时前
CentOS Stream 9 编译安装 Redis 7.2.7 完整版详细步骤
linux·redis·centos
wuminyu14 小时前
JUC组件逐层剥离与深度剖析
java·linux·c语言·jvm·c++·算法
蓝斯49714 小时前
一碰即传,重构跨设备文件分享体验
开发语言·python·重构
寒水馨14 小时前
macOS下载、安装uv-0.12.0(附安装包uv-aarch64-apple-darwin.tar.gz)
python·macos·rust·项目管理·包管理器·astral·pip替代
ocean'14 小时前
防火墙策略路由
linux·服务器·数据库
三言老师14 小时前
awk条件筛选日志内容实操
linux·运维·服务器·centos