encoding - 关于python字符编码的问题
迷茫
迷茫 2017-04-17 17:15:44
0
1
323

环境:linuxmint terminal utf-8 python2.7.6
代码如下:

#可以用16进制 >>> print '\xe5\x90\x83' 吃 #可以用8进制 >>> '%o %o %o'% (0xe5,0x90,0x83) '345 220 203' >>> print '\345\220\203' 吃 #不可以用10进制 >>> '%d %d %d'% (0xe5,0x90,0x83) '229 144 131' >>> print '\229\144\131' 9dY

问题:
为什么这里使用10进制的数,就没有办法被正确识别出来?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (1)
巴扎黑

A backslash followed by a number is an “escape character”

Transfer character rules
ddd three octal digits
xhh two hexadecimal digits

For details:
http://baike.baidu.com/link?url=Xk4gncQiT9fRjBkPCNzDBa58Q52DwJ4ldsB2kTcAxvJge0mg2AyT0JY0Y05nhfnLuKujguySGKsc2qq5WZFCLq

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!