摘要: py2编码 tr和unicode str和unicode都是basestring的子类。严格意义上说,str其实是字节串,它是unicode经过编码后的字节组成的序列。对UTF-8编码的str'苑'使用len()函数时,结果是3,因为utf8编码的'苑' == '\xe8\x8b\x91'。 而un 阅读全文
posted @ 2019-12-09 21:55 Stary_tx 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #_author:来童星#date:2019/12/9import jsons='star'a=s.encode('utf8')print(s,type(s))# star <class 'str'>print(a.decode('utf8'))# stars1='星星' # unicode类型,一 阅读全文
posted @ 2019-12-09 18:24 Stary_tx 阅读(275) 评论(0) 推荐(0) 编辑
摘要: #coding:utf8#一#1.在python2中,默认以ASCII编码chcp 936import sysprint sys.getdefaultencoding()# ascii#str:bytess1='来星hello' #存的是字节,数据类型是str(bytes就是str)# print 阅读全文
posted @ 2019-12-09 18:23 Stary_tx 阅读(419) 评论(0) 推荐(0) 编辑