疫情的原因,各种健康码,各种行程码的统计,通过群截图,收集起来真是头疼的事情,为了彻底解决这个麻烦的事情,我利用了腾讯文档的搜集表功能,和PYTHON脚本实现自动化处理。文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
首先我们去腾讯文档中,建立一个搜集表,将需要上传的图片,设置为图片题目,这样就用户就能上传图片了。文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
其次,在腾讯文档的后台,去 EXCEL 中查看结果,可以看见图片是一个连接,鼠标移入可以查看截图,腾讯还很良心的有导出功能,导出后,就是一个标准的 EXCEL 文件,这对我们来说就是非常完美的,有了 EXCEL ,接下来那就非常简单了。文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
代码能说明一切问题:文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
import openpyxl
import requests
workbook = openpyxl.load_workbook(r"1.xlsx")
booksheet = workbook.active
rows = booksheet.rows
columns = booksheet.columns
for row in rows:
i = 0
for cell in row:
if cell.value is None:
pass
else:
i = i + 1
if i == 3:
name = cell.value
if i == 4:
if "问题" in str(cell.value):
image = requests.get(cell.hyperlink.target).content
with open('./img/' + str(name) + '_' + "爸爸_" + '.jpg', 'wb')as fp:
fp.write(image)
print(cell.hyperlink.target)
if i == 5:
print(i)
if "问题" in str(cell.value):
image = requests.get(cell.hyperlink.target).content
with open('./img/' + str(name) + '_' + "妈妈_" + '.jpg', 'wb')as fp:
fp.write(image)
print(cell.hyperlink.target)
print("=====================")
文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
该脚本,就是依据文档中的数据,自动下载图片,并根据学生姓名进行命名,本脚本傻傻的处理了,你也可以发挥你的特长,自动的适配各种需求。文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html
文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html 文章源自陈学虎-https://chenxuehu.com/article/2021/06/7704.html















评论