print "4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf".decode('base64')#no
谢谢
以及
如果我有
如何获取字符串“4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf”
是
^{pr2}$我写道:
print u'4-12个英文字母、数字和下划线'.encode('unicode-escape')
it打印
4-12\xb8\xf6\xd3\xa2\xce\xc4\xd7\xd6\xc4\xb8\xa1\xa2\xca\xfd\xd7\xd6\xba\xcd\xcf\xc2\xbb\xae\xcf\xdf
不是字符串“4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf
print u'4-12个英文字母、数字和下划线'.decode('utf-8').encode('unicode-escape')
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "encodings\utf_8.pyo", line 16, in decode
UnicodeEncodeError: 'ascii' codec can't encode characters in position 4-27: ordinal not in range(128)
没有“u”也是错误:
print '4-12个英文字母、数字和下划线'.decode('utf-8').encode('unicode-escape')
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "encodings\utf_8.pyo", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb8 in position 4: unexpected code byte
没关系,谢谢
>>> print '4-12个英文字母、数字和下划线'.decode('gb2312').encode('unicode-escape')
4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf
您的最后评论:
仅当源文件以gb2312编码保存时才有效。确保在文件顶部声明,然后可以使用Unicode字符串:
^{pr2}$它被编码为python-unicode文本:
该字符串只需将其输入到JavaScript解释器(在本例中为WebKit检查器)中,就可以显示“4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、4-12、。在
它似乎没有任何base64编码的信息。在
你还有什么想知道的吗?在
相关问题 更多 >
编程相关推荐