14
在Python 2你Python 2中字母Python 3的等價性是什麼?
>>> from string import *
>>> letters
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
但是在Python 3,你
>>> from string import *
>>> letters
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'letters' is not defined
它沒有定義,而digits
和whitespace
是。
什麼是letters
與Python 3中字符串模塊的等價關係?
thanx它的工作! – CosmicRabbitMediaInc 2012-03-05 04:07:39
@CosmicRabbitMediaInc:請注意,只有在您甚至遇到英文文本時纔會有效。 – 2012-03-05 05:53:11
對我來說,我不得不刪除'string.'部分。簡單地使用'ascii_letters'在我的python 3.6上工作 – 2017-04-21 13:36:48