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-docx 生成的 Word 文档打开时弹出“无法读取内容“警告
python·word·wps·文档·docx·qoder
星马梦缘12 小时前
如何切换window-ubuntu双系统【方案二】
linux·运维·ubuntu
2401_8323655213 小时前
JavaScript中rest参数(...args)取代arguments的优势
jvm·数据库·python
Sirius.z13 小时前
第J3周:DenseNet121算法详解
python
2301_7796224113 小时前
Go语言怎么用信号量控制并发_Go语言semaphore信号量教程【入门】
jvm·数据库·python
丑八怪大丑13 小时前
Java网络编程
linux·服务器·网络
2301_7662834413 小时前
c++如何将控制台输出保存到文件_cout重定向到txt【详解】
jvm·数据库·python
橙子也要努力变强14 小时前
信号捕捉底层机制-机理篇2
linux·服务器·c++
秋914 小时前
MySQL 8.0.46 全平台安装与配置详解(Windows/Linux/macOS)
linux·windows·mysql
小康小小涵15 小时前
基于ESP32S3实现无人机RID模块底层源码编译
linux·开发语言·python