Python 2中Python 3中字母的等价性是什么?

Cos*_*Inc 24 python python-3.x

在Python 2中你得到了

>>> from string import *
>>> letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
Run Code Online (Sandbox Code Playgroud)

但是在Python 3中,你得到了

>>> from string import *
>>> letters
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'letters' is not defined
Run Code Online (Sandbox Code Playgroud)

它没有定义,而是digitswhitespace.

lettersPython 3中字符串模块的等价性是什么?

sum*_*mea 40

尝试使用:string.ascii_letters而不仅仅是letters,在这里.

更多信息请访问:http://docs.python.org/release/3.1.3/library/string.html#string-constants

  • -1这不是*等价物.**`string.letters`的具体值是与语言环境相关的**,而不是`string.ascii_letters`. (5认同)