def serach(request):
if 'q' in request.GET:
message = u'you serached for: %s' % request.GET['q']
else:
message = u'you submitted an empty form.'
这段代码中,request.GET['q']是中文,其在网页中显示的效果则是中文的编码。
要想显示中文,就得把request.GET['q']的值赋值给一个变量:
def serach(request):
if 'q' in request.GET:
str = request.GET['q']
message = u'you serached for: %s' % str
else:
message = u'you submitted an empty form.'
网友评论