Python下载七牛图片解析正常却无法下载,请牛帮看下源码,,# -*- coding
Python下载七牛图片解析正常却无法下载,请牛帮看下源码,,# -*- coding
# -*- coding: utf-8 -*-# flake8: noqaimport osimport stringimport randomimport tempfileimport requestsfrom qiniu.compat import is_py2, bfrom qiniu.services.storage.uploader import _form_putfrom qiniu import Authfrom qiniu import BucketManageraccess_key = 'ooooo'secret_key = 'xxx'bucket_name = 'faveface'url_base = '7xj2tu.com1.z0.glb.clouddn.com'print access_keyprint secret_keyq = Auth(access_key, secret_key)def list_all(bucket_name, bucket=None, prefix=None, limit=None): print('List file...') if bucket is None: bucket = BucketManager(q) marker = None print(bucket); eof = False while eof is False: ret, eof, info = bucket.list(bucket_name, prefix=prefix, marker=marker, limit=limit) marker = ret.get('marker', None) for item in ret['items']:# print(item['key']+'.jpg')# base_url='http://%s//%s'%(url_base,item['key']+'.jpg') base_url='http://%s//%s'%(bucket_name+'.qiniudn.com',item['key']+'.jpg') print('Processing: '+base_url); private_url = q.private_download_url(base_url,expires=3600) print(private_url) #r = requests.get(private_url) #assert r.status_code == 200list_all(bucket_name)
代码如上,access_key ,secret_key 暂时匿名了,打算下载faveface中的图片,能够list出图片,但是下载出现问题,大神么帮帮忙哈。
将base_url修改成
base_url='http://%s/%s'%(url_base,item['key']+'.jpg')
key签名多了一个/
编橙之家文章,
相关内容
- Python函数直接返回与传递引用的应该如何区别怎么取舍
- Python函数内部定义之前调用报错求助,python函数,def s
- 学习机安装Python3.4.3失败提示找不到sys模块怎么办,p
- Python中浮点数int()使用技巧问题,pythonint,int()描述如下
- 请推荐一个适合查看Python文档的工具,查看python文档工
- tornado内使用Future中数据用什么方法,tornadofuture,tonado官
- Python遍历字符时将汉字和英文字符看成等同怎么写,
- Python哪个模块适合处理大量定时任务数据,python模块
- Python django haystack保存数据报SpatialError如何破,djangosp
- 请问django是并发吗?数据库操作要考虑线程安全吗,,我
评论关闭