python: str()

tx1 = '中国'
tx2 = u'中国'
print tx1
print tx2
print type(tx1)
print type(tx2)

#
<type 'str'> str()函数会把unicode的字符串转成str形式的,使用的时候要注意

print type(str(tx2))

中国
中国
<type 'str'>
<type 'unicode'>
<type 'str'>

 

posted on 2016-10-14 14:57  ZhYQ_note  阅读(184)  评论(0编辑  收藏  举报

导航