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

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

相关推荐
TechWayfarer12 小时前
IP精准定位服务在快递网点规划中的应用:如何用客户位置数据辅助选址
大数据·网络·python·tcp/ip·交通物流
剑神一笑12 小时前
Linux lsof 命令深度解析:从文件描述符到进程追踪
linux·运维·php
CSND74013 小时前
零基础学Python合集---3:字符串的定义和常用方法
人工智能·python
五月君_13 小时前
放弃 Python,Kimi 用 TS + Node.js 重写了一个 Kimi Code
开发语言·python·node.js
还是鼠鼠13 小时前
AI掘金头条新闻系统 (Toutiao News)-获取用户信息
后端·python·mysql·fastapi·web
andlbds13 小时前
解决Ubuntu20.04进入系统卡死在厂商Logo界面问题
linux·ubuntu
MIXLLRED13 小时前
解决: Ubuntu 22.04上树莓派4B扩展板ROS2兼容性修复指南
linux·ubuntu·树莓派
zizle_lin13 小时前
CentOS配置yum源
linux·运维·centos
Cloud_Shy61813 小时前
解读《Effective Python 3rd Edition》:从练气到老魔
开发语言·python
SunnyDays101113 小时前
Python 操作 Excel 超链接:添加网页、文件、工作表和图片链接
python·excel