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

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

相关推荐
这里有鱼汤5 分钟前
首个开源金融平台,一站式数据终端 + AI 代理,量化研究者的利器,速来白嫖
后端·python
这里有鱼汤7 分钟前
Python量化实战:如何用Python实现查找相似K线,附源码,建议收藏
后端·python
是阿建吖!8 分钟前
【Linux | 网络】传输层(UDP和TCP) - 两万字详细讲解!!
linux·网络·udp·tcp
小阿鑫11 分钟前
使用 Kiro AI IDE 3小时实现全栈应用Admin系统
前端·后端·python·admin·kiro·next admin·fastapi admin
Java初学者小白11 分钟前
秋招Day21 - Linux
java·linux·运维·服务器
lemoncat812 分钟前
在Windows下读写Linux EXT文件系统文件
linux·运维·windows
Blossom.11818 分钟前
基于深度学习的医学图像分析:使用YOLOv5实现细胞检测
人工智能·python·深度学习·yolo·机器学习·分类·迁移学习
努力的小T21 分钟前
MBR和GPT分区的区别
linux·运维·服务器·gpt·云计算
你想考研啊40 分钟前
进程管理(systemd)
linux·运维·服务器
啊阿狸不会拉杆1 小时前
《Java 程序设计》第 8 章 - Java 常用核心类详解
java·开发语言·python·算法·intellij-idea