Flask下載文件使用中文名字
示例代碼
from urllib.parse import unquote, quote
..............
..............
# 文件名媳荒,使用quote函數(shù)
filename= quote('測(cè)試' + '.docx')
# 文件路徑
filepath = '/home/測(cè)試.docx'
rv = send_file(filepath, as_attachment=True, attachment_filename=filename)
rv.headers['Content-Disposition'] += "; filename*=utf-8''{}".format(filename)
return rv