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

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

相关推荐
JP-Destiny17 小时前
Linux-配置Ubuntu的IP
linux·tcp/ip·ubuntu
清水白石00817 小时前
从脚本到系统:设计一个支持插件、限流、重试与监控的 Python 异步爬虫框架
网络·爬虫·python
deepin_sir17 小时前
02 - 第一个 Python 程序
开发语言·python
徐先生 @_@|||17 小时前
pycharm/IDEA + markdown + 图床(PicList)
ide·python·pycharm·intellij-idea
ofoxcoding18 小时前
Codex 官网访问 + 完整安装教程:macOS / Windows / Linux 一次跑通(2026)
linux·windows·macos·ai
magic_now18 小时前
systemctl stop 会杀死子进程吗?
linux
sulikey18 小时前
如何在Ubuntu中判断是否已安装ncurses库
linux·运维·ubuntu·ncurses
Cat_Rocky18 小时前
Linux学习-ansible自动化
linux·学习·ansible
ZHW_AI课题组18 小时前
基于PCA与HOG特征融合的热轧钢带缺陷检测
人工智能·python·机器学习
MediaTea18 小时前
DL:扩散模型的基本原理与 PyTorch 实现
人工智能·pytorch·python·深度学习·机器学习