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

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

相关推荐
xixiaoyunya3 分钟前
虚拟机备份怎么做:镜像级与文件级搭配的完整实操方案
linux·运维·网络
墨家句子5 分钟前
服务器被反复尝试登录之后:fail2ban 加密钥登录的五道加固
linux·后端
阿明69 分钟前
进程替换【Linux】
linux·运维·服务器
用户2986985301410 分钟前
Python 中 HTML 转 PDF 的实现方法
python·html·api
sunoo-22913 分钟前
【嵌入式Linux驱动学习】Day1-Day2 全流程梳理:环境搭建→U-Boot→内核→根文件系统→驱动基础
linux·运维·驱动开发·笔记·学习·阿里云·恩智浦
答案是你20 分钟前
YOLOE 开放词汇检测 + ONNX / TensorRT 推理,开源了!
python·深度学习·yolo·目标检测·计算机视觉·视觉检测
2601_9628857225 分钟前
AlphaFeed 支持哪些 K 线周期?period参数怎么传?
前端·数据库·python
老歌老听老掉牙29 分钟前
基于 Python 的顺次文本拼接:以 MCD 数控文件为例
python·数控·mcd
朝朝辞暮i31 分钟前
VLA 系统学习第 7 课:loss.backward() 到底做了什么?——从计算图到反向传播
人工智能·python·深度学习·神经网络·vla
外收内放1 小时前
Python基础语法练习题(53-54)
python·学习