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

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

相关推荐
郝学胜_神的一滴6 分钟前
Python 高级编程 025:二分利器bisect模块:优雅维系有序序列,极致优化检索性能
python·pycharm
笑锝没心没肺21 分钟前
yum update 报错:GPG key retrieval failed: [Errno 14] HTTPS Error 404 - Not Found
linux·运维·服务器
小陈工22 分钟前
第8篇:Flask轻量级框架与扩展生态深度解析(下)
后端·python·面试
这就是佬们吗26 分钟前
Python入门③-运算符、条件与循环
开发语言·数据库·vscode·python·pycharm·编辑器
小刘学技术30 分钟前
AI人工智能中的类别不平衡问题:成因、影响与解决方案
开发语言·人工智能·python·机器学习
AAA@峥32 分钟前
CentOS Stream8 基于 Packstack 搭建 OpenStack 云平台全流程实战
linux·centos·openstack
汤永红35 分钟前
gtk-x11-2.0.so.0
linux·运维·服务器
郝同学今天有进步吗39 分钟前
构建 LangGraph Code Review Agent(二):建立仓库路径安全边界
python·ai·code review
雨师@1 小时前
python通过rust编写组件扩展自己的能力
python·rust
Yana.nice1 小时前
Linux logrotate 日志切割未生效
linux·运维·服务器