Python为字符串中的字母返回整数?

tij*_*jko -4 python string ascii

我正在尝试将一串字母转换为整数,将'ABC'称为'123'.

Joh*_*ooy 5

>>> import string
>>> trans = string.maketrans("ABC","123")
>>> "ABC".translate(trans)
'123'
Run Code Online (Sandbox Code Playgroud)