django xlsx中文亂碼問題解決:django
詳情: Python3.x在django中如何設置Content-Disposition,才能讓瀏覽器正確保存中文命名的文件?segmentfault
from django.utils.encoding import escape_uri_path
from django.http import HttpResponse def test(request): file_name = '測試.txt' content = ... response = HttpResponse(content, content_type='application/octet-stream') response['Content-Disposition'] = "attachment; filename*=utf-8''{}".format(escape_uri_path(file_name)) return response