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

前端 未结 10 2283
生来不讨喜
生来不讨喜 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:17

    Strings are not bytes.

    This is a simple definition in Python 3.

    Strings are Unicode (which are not bytes) Unicode strings use "..." or '...'

    Bytes are bytes (which are not strings) Byte strings use b"..." or b'...'.

    Use b"aeiou" to create a byte sequence composed of the ASCII codes for certain letters.

提交回复
热议问题