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. c++获取类型信息

    获取类型信息 typeid typeid运算符用来获取一个表达式的类型信息. 对于基本类型数据, 类型信息比较简单, 主要指数据的类型; 对于对象(类类型的数据), 类型信息指: 对象所属的类, 所包 ...

  2. Eclipse git提交代码 覆盖问题

    创建本地分支 拉取远程分支到本地 进行代码更新 然后 commit  然后将本地代码推送到远程分支 再发起合入请求 使用elipse 提交合入代码时, 注意push 提交远程分支时,  选择中  要选 ...

  3. java开发细节

    Java开发细节 Java源文件以.java 为扩展名.源文件的基本组成部分为类(class),如本类中的Hello类 Java应用程序的执行入口是main()方法.它有固定的书写格式: public ...

  4. ns 状态为Terminating

    kubectl delete ns harbor --force --grace-period=0harbor状态为Terminatingkubectl proxy --port=6880kubect ...

  5. Minio客户端工具mc

    简介:mc(Minio Client)是Minio提供访问和操作服务端的客户端工具,有Windows和Linux两个平台版本. 一.安装(基于Linux) 1. mc下载:wget https://d ...

  6. cenots7 rpm 包升级ssh

    rpm下载地址 也可以自行官网下载 链接: https://pan.baidu.com/s/1S945MehpmZbIriKK6l7Sfw 提取码: y5ua centos7rpm包升级ssh 逻辑思 ...

  7. Linux 在miniconda和anaconda同时安装时,卸载miniconda

    1. 找到miniconda目录,删除. rm -rf miniconda3/ 2. 编辑bashrc sudo vim .bashrc setup路径改回anaconda3的,注释掉"&g ...

  8. web开发(2): html标签/web语义化

    chapter2 html 标签 在sublime中敲入!, 按tab 进行拓展,得到如下框架 <!DOCTYPE html> <html lang="en"&g ...

  9. win10家庭版升级为专业版

    1.选择此电脑点击属性 2.点击更改产品密匙 3.输入产品密匙 4N7JM-CV98F-WY9XX-9D8CF-369TT下一步等待升级重启即可.

  10. 用requests-html和SelectorGadget轻松精准抓取网页数据

    我们在抓取网页数据时,最常採用Python的requests搭配BeautifulSoup的模式来完成.然而,requests-html整合了上述2个套件,又添加了新的功能,或许是抓取网页数据值得考虑 ...