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

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

相关推荐
专注搞钱12 小时前
用Python写了个SPC自动分析工具,效率提升10倍
开发语言·python
小则又沐风a13 小时前
进程最终篇---进程控制(模拟实现xshell)
java·linux·服务器·前端
yijianace13 小时前
Python爬虫实战:ThreadPoolExecutor多线程采集书籍信息与图片下载
开发语言·爬虫·python
_codemonster13 小时前
K8s / K3s 通用 Kubectl 命令大全(表格版)
linux·docker·kubernetes
阿旭超级学得完13 小时前
Linux基础指令 四(apt,vim,git,cgdb)
linux·服务器·开发语言·数据结构·c++·git·vim
半夜修仙13 小时前
4.RabbitMQ运维
linux·运维·服务器·分布式·rabbitmq·java-rabbitmq
郝亚军13 小时前
win11安装python3.12.7和pycharm
ide·python·pycharm
ALINX技术博客13 小时前
【黑金云课堂】FPGA技术教程Linux开发:摄像头GPU渲染显示/Qt OpenGLES使用
linux·qt·fpga开发·gpu
资深流水灯工程师13 小时前
PyCharm 虚拟环境完整配置指南(PySide6 开发专用)
ide·python·pycharm
宸津-代码粉碎机13 小时前
Spring AI企业级实战|Agent长期记忆持久化落地,彻底解决多轮对话上下文丢失问题
java·开发语言·人工智能·后端·python·spring