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

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

相关推荐
hboot6 小时前
AI工程师第二课 - 数据处理
人工智能·python·数据分析
用户83562907805110 小时前
使用 Python 自动化 PowerPoint 形状布局与格式设置
后端·python
AlfredZhao10 小时前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户83562907805112 小时前
用 Python 自动化 PowerPoint 演讲者备注添加
后端·python
用户97183563346616 小时前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
黄忠18 小时前
01-系统架构设计-LangGraph状态机与多源异构RAG
python
zzzzzz31018 小时前
假如我是掘金管理员,我先给评论区装个'代码审查'系统
python·程序员·机器人
猪脚踏浪18 小时前
linux 拷贝文件或目录到指定的位置
linux
砍材农夫18 小时前
python环境|conda安装和使用(2)
后端·python
程序员龙叔1 天前
编写高质量 Skill 系列 -- 如何设计需求分析与用例生成的 SKILL
自动化测试·软件测试·python·软件测试工程师·接口测试·性能测试·skill·ai测试