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. N63050 第十四周运维作业

    就业和全程班小伙伴本周学习内容: 第二十七天: http协议和web服务器 1http的cookie和session详解 2LAMP架构和CGI与FASTCGI区别 3常见PHP的配置和php程序 4 ...

  2. python连接数据库系列

    1.Python连接MySQL 具体详情参考:MySQL笔记 Python连接MySQL需要借助pymysql,安装pymysql pip install pymysql 1.1 pymysql连接数 ...

  3. containerd 卸载

    一.创建脚本 cat > remove.sh <<EOF #!/bin/bash # 删除contained命令及配置 rm -rf /usr/local/bin/ rm -rf / ...

  4. java中使用 MultipartFile 进行文件上传而且指定了上传的临时路径,但是文件上传成功后,显示临时文件 无法删除为什么

    来自 AI BOT 回复:这是因为文件可能正在被应用程序使用,即文件已经被Java程序锁定,使得系统无法对其进行修改或删除.为了解决这个问题,你需要在保存完文件之后把它移动到正确的位置,或者在Java ...

  5. Sql Sugar 拾遗

    SqlSugar 拾遗 更新操作 //UpdateColumns:只更新某些列 db.Updateable(entity).UpdateColumns(it => new { it.Name } ...

  6. linux下启动rabbitmq,redis,nginx

    这只是其中一种启动方法,也是我自己安装好后试过多次可以用的, 1,启动rabbitmq rabbitmqctl start_app rabbitmq程序端口是5672,可视化界面入口端口是15672, ...

  7. Ubuntu子系统shell脚本自动连接xfce4界面

    脚本功能 命令行参数指定ip连接/获取ifconfig中的本地ip连接 修改.bashrc #!/bin/bash net_dev="wifi0" #默认的设备名 FALSE=&q ...

  8. C# 前台线程 后台线程区别

    前台线程 会随进程一起结束 不管是否完成,后台线程需要执行完毕,进程才能结束 例子: class Program { static void Main(string[] args) { Thread ...

  9. koa获取get和post的参数实例代码

    1 const Koa = require('koa'); 2 const Router = require('koa-router');//引用koa-router 3 const KoaBody ...

  10. 无锁并发,CAS等

    Unsafe