提交 e02f6b92 编写于 作者: L liuzf1

增加💻通过内容,查找文件

上级 a2e7119f
......@@ -30,11 +30,8 @@ MANIFEST
# demo
.idea/
.gitee/
shell/upload.sh
test/
test/clean.sh
test/allpackages.txt
shell/
# PyInstaller
# Usually these files are written by a python script from a template
......
......@@ -11,6 +11,7 @@
import os
from alive_progress import alive_bar
import glob
def replace4filename(path, del_content, replace_content=None):
......@@ -35,3 +36,23 @@ def replace4filename(path, del_content, replace_content=None):
os.rename(path + os.sep + old_file_name, path + os.sep + new_file_name)
work_count = work_count + 1
print("当前目录下,共有{}个文件/文件夹,本次运行共进行了{}个文件/文件夹的重命名".format(len(fileList), work_count))
def search_by_content(search_path, content): # 定义 search() 函数,传入 "path" 文件路径, "target" 要查找的目标文件
"""
获取当前路径下所有内容
判断每个内容的类型(文件夹还是文件)
若是文件夹则继续递归查找
"""
glob_path = glob.glob(search_path)
for file_path in glob_path: # for 循环判断递归查到的内容是文件夹还是文件
if glob.os.path.isdir(file_path): # 若是文件夹,继续将该文件夹的路径传给 search() 函数继续递归查找
_path = glob.os.path.join(file_path, '*')
search_by_content(_path, content)
else: # 若是文件,则将该查询到的文件所在路径插入 final_result 空列表
try:
with open(file_path, 'r') as file: # 利用 open() 函数读取文件,并通过 try...except... 捕获不可读的文件格式(.zip 格式)
if content in file.read():
print('该文件内,包含:【{}】'.format(content) +' | '*2+ file_path)
except:
continue
from . import weather_service
\ No newline at end of file
import requests
import re
#天气爬虫
def weather_spider(url,headers):
response = requests.get(url,headers)
content = response.content.decode('utf-8')
pat_weather = re.compile('<input type="hidden" id="hidden_title" value="(.*?)" />')
pat_up_time = re.compile('<input type="hidden" id="fc_24h_internal_update_time" value="(.*?)"/>')
weather = pat_weather.findall(content)
up_time = pat_up_time.findall(content)
print(weather[0])
print('更新时间:',up_time[0])
ask_ok = input('是否深入查看(Y/N):')
if ask_ok == 'Y' or ask_ok == 'y':
pat_more_weather = re.compile('<li class="li. hot".*?\n<i></i>.<span>(.*?)</span>\n<em>(.*?)</em>\n<p>(.*?)</p>.*?\n</li>',re.S)
more_weather = pat_more_weather.findall(content)
for item in more_weather:
if item[1] != '减肥指数':
print(item[1],':',item[0],',',item[2])
else:
print(item[1],':',item[2])
about-time==3.1.1
alive-progress==2.4.1
certifi==2021.10.8
charset-normalizer==2.0.12
click==8.1.3
colorama==0.4.4
commonmark==0.9.1
decorator==4.4.2
easyocr==1.4.2
et-xmlfile==1.1.0
fpdf==1.7.2
grapheme==0.6.0
idna==3.3
imageio==2.19.1
imageio-ffmpeg==0.4.7
importlib-metadata==4.11.3
libretranslatepy==2.1.1
lxml==4.8.0
moviepy==1.0.3
networkx==2.6.3
numpy==1.21.6
opencv-python-headless==4.5.4.60
openpyxl==3.0.9
packaging==21.3
pandas==1.3.5
pikepdf==5.1.2
Pillow==9.1.0
proglog==0.1.10
progress==1.6
Pygments==2.12.0
pyparsing==3.0.8
PyPDF2==1.27.12
pypiwin32==223
python-bidi==0.4.2
python-dateutil==2.8.2
python-docx==0.8.11
python-office @ file:///D:/workplace/code/BaiduNetdiskWorkspace/personal/linux/workplace/pro/git/gitee/python-office
python-pptx==0.6.21
pytz==2022.1
PyWavelets==1.3.0
pywin32==304
PyYAML==6.0
qrcode==7.3.1
reportlab==3.6.9
requests==2.27.1
rich==12.4.1
scikit-image==0.19.2
scipy==1.7.3
six==1.16.0
tifffile==2021.11.2
torch==1.11.0
torchvision==0.12.0
tqdm==4.64.0
translate==3.6.1
typing_extensions==4.2.0
urllib3==1.26.9
xlrd==2.0.1
XlsxWriter==3.0.3
xlutils==2.0.0
xlwings==0.27.7
xlwt==1.3.0
zipp==3.8.0
pip freeze > allpackages.txt
pip uninstall -r allpackages.txt -y
pip install --upgrade python-office
\ No newline at end of file
rm -rf ./dist/* ./build/*
python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*
from . import weather
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册