Flask下载文件使用中文名字
示例代码
from urllib.parse import unquote, quote
..............
..............
# 文件名,使用quote函数
filename= quote('测试' + '.docx')
# 文件路径
filepath = '/home/测试.docx'
rv = send_file(filepath, as_attachment=True, attachment_filename=filename)
rv.headers['Content-Disposition'] += "; filename*=utf-8''{}".format(filename)
return rv
网友评论