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

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

相关推荐
2601_956319882 分钟前
最新量化开发卡住,先查规则和流程是否完整
人工智能·python
小小代码狗27 分钟前
SQLi-Labs 基础注入实战教程(Less-1 ~ Less-5and Less-9)
服务器·python·php
慕伏白30 分钟前
【慕伏白】Linux 系统如何根据端口号关闭进程
linux·运维·服务器
letisgo51 小时前
VMware Workstation + Ubuntu 26.04 LTS 小白运维部署手册
linux·运维·ubuntu
IT探索1 小时前
Linux 查找文件指令总结
linux·算法
晚风吹长发1 小时前
Docker使用——Docker容器及相关命令
linux·运维·服务器·docker·容器·架构
nanawinona1 小时前
2026年下半年量化学习,不同基础要查不同缺口
人工智能·python
sulikey1 小时前
个人Linux操作系统学习笔记11 - 环境变量
linux·笔记·学习
CTA量化套保1 小时前
最新量化表达入门,从概念规则到简单实现
人工智能·python
Kina_C1 小时前
NFS与Autofs快速讲解-从原理到实战配置
linux·nfs·autofs