Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想得到,给定一个角色,它的ASCII价值。
ASCII
例如,对于角色a,我想得到97,反之亦然。
a
97
使用chr()和ord():
chr()
ord()
>>> chr(97) 'a' >>> ord('a') 97
>>> ord('a') 97 >>> chr(97) 'a'
ord 和 chr
对于长字符串,您可以使用它。
''.join(map(str, map(ord, 'pantente')))