用django写了一个网站,
需让远端下载pdf档,
程式码如下
def download(request):
with open('f:/test.pdf','r') as f:
response=HttpResponse(f.read(),content_type='application/pdf')
response['Content-Disposition'] = 'attachment;filename=test.pdf'
在f.read()发生错误,
'cp950' codec can't decode byte 0x9c in position 519: illegal multibyte
sequence
我用FileWrapper(f)取代f.read()依旧得到相同讯息,
请高手相助!