utf8' codec can't decode byte 0xc0 in position 227:invalid start byte,代码如下:#encoding=utf8 from blog.models import Article,Tag,Classificationfrom django.shortcuts import render_to_responsefrom django.template import RequestContextdef blog_li

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 03:29:19
utf8' codec can't decode byte 0xc0 in position 227:invalid start byte,代码如下:#encoding=utf8 from blog.models import Article,Tag,Classificationfrom django.shortcuts import render_to_responsefrom django.template import RequestContextdef blog_li

utf8' codec can't decode byte 0xc0 in position 227:invalid start byte,代码如下:#encoding=utf8 from blog.models import Article,Tag,Classificationfrom django.shortcuts import render_to_responsefrom django.template import RequestContextdef blog_li
utf8' codec can't decode byte 0xc0 in position 227:invalid start byte,
代码如下:
#encoding=utf8
from blog.models import Article,Tag,Classification
from django.shortcuts import render_to_response
from django.template import RequestContext
def blog_list(request):
blogs = Article.objects.all().order_by('-publish_time')
return render_to_response('index.html',{'blogs':blogs},context_instance=RequestContext(request))
错误是
UnicodeDecodeError at /
'utf8' codec can't decode byte 0xc0 in position 227:invalid start byte
Request Method:
GET
Request URL:
Django Version:
1.7
Exception Type:
UnicodeDecodeError
Exception Value:
'utf8' codec can't decode byte 0xc0 in position 227:invalid start byte
Exception Location:
D:\Python\lib\encodings\utf_8.py in decode,line 16
Python Executable:
D:\Python\python.exe
Python Version:
2.7.8
Python Path:
['E:\\Django\\dblog',
'D:\\Python\\lib\\site-packages\\setuptools-6.0.3dev-py2.7.egg',
'D:\\Python\\lib\\site-packages\\django-1.7-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'D:\\Python\\DLLs',
'D:\\Python\\lib',
'D:\\Python\\lib\\plat-win',
'D:\\Python\\lib\\lib-tk',
'D:\\Python',
'D:\\Python\\lib\\site-packages',
'D:\\Python\\lib\\site-packages\\win32',
'D:\\Python\\lib\\site-packages\\win32\\lib',
'D:\\Python\\lib\\site-packages\\Pythonwin']
Server time:
Mon,6 Oct 2014 12:05:00 +0800
指向了最后一行

utf8' codec can't decode byte 0xc0 in position 227:invalid start byte,代码如下:#encoding=utf8 from blog.models import Article,Tag,Classificationfrom django.shortcuts import render_to_responsefrom django.template import RequestContextdef blog_li
不行就转一下码试试.%D%A%D%A user['UserName'].encode('gbk') 或者是utf8,utf16,看你user里面的编码了.