from aiohttp import web
from urllib.parse import quote

r = web.Response()
# r.content_type = 'application/octet-stream'
# r.content_disposition = 'attachment;filename={}'.format('语言包.xlsx')
r.headers['content_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
r.headers["Cache-Control"] = "no-cache"
filename = '官网语言包{}.xlsx'.format(datetime.datetime.now().strftime('%Y%m%d %H%M%S'))
r.headers["Content-Disposition"] = "attachment;filename*=UTF-8''{}".format(quote(filename.encode('utf-8')))
r.body = sio.getvalue()
return r

python下载文件headers的更多相关文章

  1. 【331】python 下载文件:wget / urllib

    参考:python下载文件的三种方法(去掉-) 方法一:wget import wget, os # 设置下载路径 os.chdir(r"D:/tmp") url="ht ...

  2. python下载文件的三种方法

    Python开发中时长遇到要下载文件的情况,最常用的方法就是通过Http利用urllib或者urllib2模块. 当然你也可以利用ftplib从ftp站点下载文件.此外Python还提供了另外一种方法 ...

  3. python下载文件(图片)源码,包含爬网内容(爬url),可保存cookie

    #coding=utf-8 ''' Created on 2013-7-17 @author: zinan.zhang ''' import re import time import httplib ...

  4. python 下载文件 & 防盗链

    偶然下载一种类型的资源,发现好多翻页,右键另存什么的,不胜其烦. 决定用python写几句代码搞定.核心代码如下: from urllib import urlretrieve from urllib ...

  5. python下载文件的方法

    前一段时间是爬文字,最近准备爬图片 找到了两种保存文件的方法 一种是用urllib.urlretrieve方法 #-*- coding: utf-8 -*- import urllib def cal ...

  6. 使用Python下载文件

    python -c "with open('/tmp/file.sh', 'wb') as f: import urllib2; f.write(urllib2.urlopen('http: ...

  7. python下载文件

    import urllib import urllib2 import requests url = "http://www.blog.pythonlibrary.org/wp-conten ...

  8. 转:python webdriver API 之下载文件

    webdriver 允许我们设置默认的文件下载路径.也就是说文件会自动下载并且存在设置的那个目录中.要想下载文件,首选要先确定你所要下载的文件的类型.要识别自动文件的下载类型可以使用 curl ,如图 ...

  9. 【转】【Python】python使用urlopen/urlretrieve下载文件时出现403 forbidden的解决方法

    第一:urlopen出现403 #!/usr/bin/env python # -*- coding: utf- -*- import urllib url = "http://www.go ...

  10. python 读取mysql存储的文件路径下载文件,内容解析,上传七牛云,内容入es

    #!/usr/bin/env python # -*- coding: utf-8 -*- import ConfigParser import json import os import re fr ...

随机推荐

  1. celery+redis的使用(异步任务、定时任务)

    目录 celery理解 安装celery+redis 异步任务使用 1.基础使用 新建task.py文件 在项目文件目录下执行python交互式编程 在项目文件目录下创建worker消费任务 2.使用 ...

  2. djangoDRF查询

    DRF全部查询基础示例 from django.db.models import Q, F, Sum, Avg, Count, Min, Max from rest_framework.respons ...

  3. mysql主从故障跳过错误

    mysql主从故障跳过错误1.从库报错 21,22,23,25无法执行Retrieved_Gtid_Set: 265c6c2a-86ca-11ed-b07a-0242ac120002:1-25Exec ...

  4. vue项目去掉网页滚动条

    点击查看代码 <template> <div id="app"> <router-view /> </div> </templ ...

  5. web-bootstrap-button

    20:51:55 页面上两个button 并列,且空出间隔.

  6. 错误:/etc/sudoers: syntax error near line

    错误 yang@ubuntu:/etc$ sudo cat sudoers >>> /etc/sudoers: syntax error near line 26 <<& ...

  7. java学习:八大基本类型变量

    1.类 在java中用class来定义一个类,类是java程序的基本单位 类描述的是具有共性的一类事物,所以我们又可以把类称作为模板技术   如何理解共性: 具有相同的属性-->java变量 具 ...

  8. certutil工具使用和bypass学习

    乌鸦安全的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站.服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作.利用此文所提供 ...

  9. web安全学习笔记(2022/8/26)

    网络安全Web学习笔记 @author: lamaper @email: lamaper@qq.com @blog: lamaper - 博客园 (cnblogs.com) @date: Aug.26 ...

  10. Laravel ORM 常用方法

    1. 数据查询 ->find($id);  //需要一个主键$id并返回一个模型对象.若不存在则返回null ->findOrFail($id);  //需要一个主键$id并返回一个模型对 ...