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 小时前
Linux静态库:多模块高效管理
linux·运维·服务器
web3.08889995 小时前
微店商品详情API实用
python·json·时序数据库
公子烨6 小时前
linux的斩杀线之OOM操控
linux
知乎的哥廷根数学学派6 小时前
基于数据驱动的自适应正交小波基优化算法(Python)
开发语言·网络·人工智能·pytorch·python·深度学习·算法
sunfove6 小时前
将 Python 仿真工具部署并嵌入个人博客
开发语言·数据库·python
Learner6 小时前
Python类
开发语言·python
wgl6665206 小时前
Linux---基础IO!
linux·运维·服务器
2501_941329726 小时前
门及其组件定位识别_YOLO13-C3k2-PoolingFormer改进模型研究
python
Ancelin安心6 小时前
kali-dirsearch的使用
linux·运维·服务器·python·计算机网络·web安全·网络安全
努力学习的小洋6 小时前
Python训练打卡Day5离散特征的处理-独热编码
人工智能·python·机器学习