UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 140: invalid continuation byte

web阅片系统,遇到dicom文件在文件夹不能正常读取的问题。解决方法如下:


def rep7(request):
file_path = os.path.dirname(__file__) + request.path
with open(file_path, 'rb') as file:
response = HttpResponse(file)
response['Content-Type'] = 'application/dicom'
return response
原文地址:https://www.cnblogs.com/theWinter/p/9578746.html