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

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

相关推荐
鹿鹿学长1 分钟前
发题前三天,组委会在过三道关:赛题七渠道首发、知网统一收卷、AI 详情 PDF 首进支撑材料
python·自动化
w01_02_034 分钟前
linux, 桌面, 自启动。
linux·运维·服务器
从零开始的嵌入式之旅27 分钟前
day36
linux·c语言·经验分享·笔记·嵌入式硬件
geovindu39 分钟前
python: Face Recognition
开发语言·后端·python·人脸识别
吴声子夜歌44 分钟前
Linux命令——查找文件
linux·运维·学习
mounter62544 分钟前
Linux 内核 binfmt_misc 深度全景解析:历史、架构、安全
linux·安全·linux kernel·kernel
2601_954811821 小时前
AI科学实验室MHS标准解读:AI智能体如何统一控制实验室设备接口
人工智能·python
一位正在转型AI全栈的前端工程师1 小时前
AI 全栈学习之旅 -Week 9:什么是AI Agent?从Function Calling到LangGraph
前端·python
用户0332126663671 小时前
使用 Python 为 PowerPoint 设置背景色和背景图【附代码示例】
python
ever_up9731 小时前
LangChain基础知识概述1
人工智能·python·langchain