admin管理员组文章数量:1652184
2、编写一个脚本实现长传图片,命名为:pic_upload.py
import progressbar
from baidupcsapi import PCS
class ProgressBar():
def __init__(self):
self.first_call = True
def __call__(self, *args, **kwargs):
if self.first_call:
self.widgets = [progressbar.Percentage(), ' ', progressbar.Bar(marker=progressbar.RotatingMarker('>')),
' ', progressbar.ETA()]
self.pbar = progressbar.ProgressBar(widgets=self.widgets, maxval=kwargs['size']).start()
self.first_call = False
if kwargs['size'] <= kwargs['progress']:
self.pbar.finish()
else:
self.pbar.update(kwargs['progress'])
pcs = PCS('杜如意8','dxy199113')
test_file = open('example_04.jpg','rb').read()
ret = pcs.upload('/',test_file,'example_04.jpg',callback=ProgressBar())
3、在虚拟环境pi_py3环境下运行:
python3 pic_upload.py
要输入图片的验证码,还要接收邮箱的数字验证码,有些麻烦
版权声明:本文标题:python下载百度网盘文件-python通过百度云api的方式上传或下载文件 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1729576965a1207217.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论