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

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

相关推荐
码云骑士24 分钟前
97-Milvus从零到生产-Standalone-vs-Cluster-索引选择-分片监控扩容
python·milvus
草莓熊Lotso29 分钟前
【Linux网络】从0手写Reactor反应堆(二):完善核心细节——ET非阻塞读写、分层架构与回调机制
linux·运维·服务器·网络·c++·tcp/ip·架构
accept 99%29 分钟前
python版提取 PDF 的常用第三方库与工具
开发语言·python·pdf
小猴子爱上树36 分钟前
跨境图片翻译工具,批量处理商品图视频字幕
python·音视频
mounter62538 分钟前
深度解析 eBPF LSM:如何利用 eBPF 构建安全的 Linux 内核纵深防御体系
linux·安全·ebpf·linux kernel·kernel
用户2986985301441 分钟前
HTML 转 Word 指南:新手入门教程
人工智能·后端·python
Livia要学习44 分钟前
Python面向对象三大特性:封装、继承、多态
开发语言·python
Csvn1 小时前
🐍 Day1 : Python 环境搭建 — 现代 Python 工作流
后端·python
杨_晨1 小时前
LLM输出康熙部首冲突
数据库·python·mysql·ai
渣男教父1 小时前
Python-lxml 与 XPath 实战
python·编程语言