【发布时间】:2015-09-23 17:36:19
【问题描述】:
为什么我会从下面的代码中收到标题中的错误消息?
编辑:因为我没有注意我是如何写“ascii”的。谢谢大家
下面的代码在我的 Iphone IDE 上运行良好,但在我的 Windows 7 上运行良好(带有 Notepad++ 和命令提示符)。我检查了目录以查看是否存在任何我没有看到的 string.py 文件。我在我的桌面上进行了搜索,发现了 4 个名为该文件的文件,其中两个表示它们已被遵守。我删除了编译的文件并留下了另外两个。我是菜鸟。
import string
import random
x = string.acsii_letters
y = random.choice(x)
print y * 5
【问题讨论】:
-
什么版本的python?
-
@ChadSimmons python 2.7 每个标题
-
是
ascii不是acsii -
你会得到的错误是
AttributeError: 'module' object has no attribute 'acsii_letters'有趣的是你在标题中发布了正确的“ascii”
标签: python python-2.7