Skip to content

Commit b9872ed

Browse files
committed
Update 110.md
增加一个unicode字符串声明方法
1 parent 40c2929 commit b9872ed

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎110.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ python2默认的编码是ascii,通过encode可以将对象的编码转换为
158158

159159
import codecs
160160
codecs.open('filename', encoding='utf8')
161+
162+
经验四:声明字符串直接加u,声明的字符串就是unicode编码的字符串
163+
164+
a = u"中"
161165

162166
我还收集了网上的一片文章,也挺好的,推荐给看官:[Python2.x的中文显示方法](https://github.com/qiwsir/ITArticles/blob/master/Python/Python%E7%9A%84%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E6%96%B9%E6%B3%95.md)
163167

0 commit comments

Comments
 (0)