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

时间:2022-07-05 22:20:09
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