1

我将使用 Windows 版本的 PyPy阅读 Segaran 的Programming Collective Intelligence 。

作者正在逐步构建这个例子。首先加载字典:

from recommendations import critics

然后通过添加一个新函数来修改 Recommendations.py。然后读者应该重新加载模块:

reload(recommendations)

我没有成功重新加载,而是收到此错误:

>>>> reload(recommendations)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: global name 'recommendations' is not defined

难道我做错了什么?

4

1 回答 1

2

全局不存在。您需要导入建议才能使其正常工作。

于 2011-12-02T18:34:14.327 回答