- import string
- intab = 'aeiou'
- outtab = '12345'
- trantab = string.maketrans(intab, outtab)
- str = "Hello world!Hello Ralph!Hello GuoZhanxian"
- print str.translate(trantab)
- #该片段来自于http://www.codesnippet.cn/detail/181020136491.html
来源: http://www.codesnippet.cn/detail/181020136491.html