python FileResponse下载中文文件名, 无法下载的问题

前段时间写python下载excel文档时,使用的python的 FileResponse,filename是中文时,正常使用英文发现没有问题,文件可以正常下载,但是使用中文名称命名文件时,无法生成文件后缀

response['Content-Disposition'] = 'attachment;filename=测试.xls'

修改代码如下,即可正常下载中文文件,

response['Content-Disposition'] = 'attachment;filename={}'.format(escape_uri_path('测试.xls'))

猜你喜欢

转载自blog.csdn.net/sunjl_a/article/details/84562203
今日推荐