How come string.maketrans does not work in Python 3.1?

前端 未结 10 2318
生来不讨喜
生来不讨喜 2020-12-18 19:49

I\'m a Python newbie.

How come this doesn\'t work in Python 3.1?

from string import maketrans   # Required to call maketrans function.

intab = \"aei         


        
10条回答
  •  没有蜡笔的小新
    2020-12-18 20:14

    "this is string example....wow!!!".translate(str.maketrans("aeiou","12345"))
    

    This works, and no additional byte transformation. I don't know the reason why to use byte instead of str.

提交回复
热议问题