【发布时间】:2010-10-16 18:59:43
【问题描述】:
给定一个字符,我想得到它的ASCII 值。
例如对于字符a,我想得到97,反之亦然。
【问题讨论】:
标签: python integer char type-conversion
给定一个字符,我想得到它的ASCII 值。
例如对于字符a,我想得到97,反之亦然。
【问题讨论】:
标签: python integer char type-conversion
>>> ord('a')
97
>>> chr(97)
'a'
【讨论】:
ord 和 chr
【讨论】:
print ((ord and chr)(0O041))
对于长字符串,您可以使用它。
''.join(map(str, map(ord, 'pantente')))
【讨论】: