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

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

相关推荐
云泽80815 分钟前
Linux 系统编程实战:从零手写一个高性能终端进度条
linux·运维·服务器
Mapleay22 分钟前
设备树/ACPI 与 fwnode 内核基础设施
linux
2601_9622937925 分钟前
【Python教程:自动化处理文件】
python·自动化·编程·文件处理·os模块
禹凕25 分钟前
快速幂算法详解与实战
python·算法
sylviiiiiia34 分钟前
leetcode hot 100
python·算法·leetcode
半摆烂日常44 分钟前
自建WMS和买成品:三年成本对比
大数据·服务器·数据库·python·深度学习·低代码·numpy
2601_962296511 小时前
Python的哈希hashlib模块详细解读
python·md5·sha·加密算法·hashlib
chinesegf1 小时前
comfyui便携版的基础使用
python
OPEN-F1 小时前
ROS2系列教程:Gazebo插件(关节控制/IMU/激光雷达)
c++·python·数码相机·算法·机器人
临沂GEO1 小时前
芝麻开门GEO|AI数字化新趋势,助力企业线上长效增长
大数据·人工智能·python