1
2
3
4
5
6
>>> s = '编程'
>>> print s
编程
>>> s
'\xe7\xbc\x96\xe7\xa8\x8b'
>>>>>> s = '编程'
>>> print s
编程
>>> s
'\xe7\xbc\x96\xe7\xa8\x8b'
>>>
在python2中直接调用字符串的变量的话,会打印其bytes(可以理解成用16进制表示字符串的内存地址,本质还是二进制)。在p...
python报错:TypeError: can only concatenate str (not "bytes") to str
如下图:
can only concatenate str (not "bytes") to str
#接收请求数据
def search(request):
request.encoding = 'utf-8'
if 'q' in request.GET:
message = '你搜索的内容为: ' +request.GET['q'].encode('utf-8')
else:
message = '你提交了空...