UnicodeDecodeError with Django's request.FILES

后端 未结 4 1787
自闭症患者
自闭症患者 2021-02-09 04:28

I have the following code in the view call..

def view(request):
    body = u\"\"  
    for filename, f in request.FILES.items():
        body = body + \'Filename         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-09 05:28

    If you are not in control of the file encoding for files that can be uploaded , you can guess what encoding a file is in using the Universal Encoding Detector module chardet.

提交回复
热议问题