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

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

相关推荐
空心木偶☜15 分钟前
LangChain 概述
python·ai·langchain·ai编程
lie..24 分钟前
30天从零开始学AI应用开发(Day 19):项目二完结:RAG 知识库问答系统,把自己攒的资料变成私人顾问
开发语言·人工智能·python
顺风尿一寸30 分钟前
深入 Linux 6.18 挂载机制:从 VFS 到 ext4 的完整调用链
linux
她说彩礼65万1 小时前
C语言 assert
java·linux·c语言
lcj25111 小时前
【Linux】 Makefile 详解
linux·笔记·面试
郝学胜_神的一滴1 小时前
Numpy数据处理详解 01:NumPy 从环境搭建到入门上手
人工智能·python
天疆说1 小时前
腾讯会议 Linux 版在 NVIDIA 显卡上看不到画面:EGL 像素配置与窗口视觉不匹配的排查与修复
linux·数据库·腾讯会议
geats人山人海1 小时前
linux 2 基本操作与vim
linux·运维·vim
破芽1 小时前
python知识点小结01
python