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

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

相关推荐
正仪3 分钟前
systemd 是什么?
linux·运维·windows
暖核5 分钟前
华为云运维三件套实战:云审计 + 云监控 + 云日志完整操作指南
linux·运维·华为云
liliangcsdn13 分钟前
IC计算-前向/远期收益计算和代码示例
开发语言·python·pandas
2601_9623818625 分钟前
python安装好了如何设置环境变量
python·开发工具·环境变量·虚拟环境·ide配置
小柯南敲键盘36 分钟前
跨马翻译:跨境电商图片翻译工具,批量处理视频字幕与抠图
python·音视频
AI+程序员在路上36 分钟前
Rv1126b与手机(SPP蓝牙串口APP)蓝牙通信流程
linux·c语言·智能手机
Hali_Botebie42 分钟前
PyTorch 内存布局,.view()要合并哪两个维度(比如 B 和 G),这两个维度在内存里就必须“紧挨着”。
人工智能·pytorch·python
虚无的纽扣42 分钟前
【Linux】进程第二课:进程优先级和环境变量
linux·运维·服务器
maosheng11461 小时前
【无标题】linux中企业容易考的的小知识点1(rhcsa)
linux·运维·服务器
牢姐与蒯1 小时前
Linux进程(九).自定义shell——深度理解命令行和shell
linux·运维·服务器