Python 字符ASCII与数字之间的转化

Python 用到了一个将一个数字转化为  对应ASCII  的地方。。。 结果习惯性的用了  ‘a’+1 之类的  或者int('a')   , 直接报错==

后来查了查才知道--- 规则== 用的是 ord('a') 和chr(59)  之类: 记录一下吧   挺常用的

Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> ord('b')  # convert char to int
98
>>> chr(100)  # convert int to char
'd'
>>> unichr(100) # return a unicode byte
u'd'
>>>


你可能感兴趣的:(python,python,ascii)