python print 中文显示\xe3\x80
pythonPython 2.7.5 (default, Apr2 2020, 13:16:51)[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> uri="2003Theme_List
·
python
Python 2.7.5 (default, Apr 2 2020, 13:16:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> uri="2003Theme.robot:我的主题列表_冒烟流程"
>>> print uri
2003Theme.robot:我的主题列表_冒烟流程
>>> tsuite=uri.split(':', 1)
>>> print tsuite
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
2.如何解决的,使用decode('string_escape')来解决
import string
>>> print (str(tsuite).decode('utf-8'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).encode('utf-8'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).encode('utf-8').decode('gbk'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).encode('utf-8').decode('gb2312'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).encode('utf-8').decode('raw_unicode_escape'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).decode('raw_unicode_escape'))
['2003Theme.robot', '\xe3\x80\x91\xe6\x88\x91\xe7\x9a\x84\xe4\xb8\xbb\xe9\xa2\x98\xe5\x88\x97\xe8\xa1\xa8_\xe5\x86\x92\xe7\x83\x9f\xe6\xb5\x81\xe7\xa8\x8b']
>>> print (str(tsuite).decode('string_escape'))
['2003Theme.robot', '我的主题列表_冒烟流程']
>>>
更多推荐
已为社区贡献2条内容
所有评论(0)