【发布时间】:2013-04-06 00:16:15
【问题描述】:
大家好,我是 python 语言的新手,我选择了学习 python 的艰难方式来学习它并加深我的理解......我被练习 25 难住了,当我们将代码直接导入终端时
>>> import ex25
>>> sentence = "All good things come to those who wait."
>>> words = ex25.break_words(sentence)
然后我得到一个属性错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'break_words'
我正在使用 python 2.7 windows 7请帮忙.....http://learnpythonthehardway.org/book/ex25.html
【问题讨论】:
-
那么你在
ex25.py中定义了什么? -
import ex25; dir(ex25)会告诉你模块提供了哪些功能。 -
可能是 ex25 中的拼写错误,或者您没有从网页中复制/粘贴所有源代码。
-
练习链接提供了关于我输入和定义的代码的所有信息。我按照 Zeds 的指示,他跑得很好?我将再次检查代码以检查拼写错误。