【发布时间】:2020-01-13 03:14:32
【问题描述】:
我正在阅读 python 速成课程书,我想导入一个我已经编写了它的函数并将其正确保存在路径中的模块。 使用pycharm,python 3.7
我已经正确编写了代码,并且我知道它在导入的模块中存在(属性)。
代码是这样的:
def make_pizza(size, *toppings):
"""Summarize the pizza we are about to make."""
print(f"\nMaking a {size}-inch pizza with the following toppings:")
for topping in toppings:
print(f"- {topping}")
但我收到此错误AttributeError: module 'pizza' has no attribute 'make_pizza'
我不知道该怎么办,我真的需要解决这个问题才能继续学习。
【问题讨论】:
-
向我们展示引发此错误的代码,即导入代码
-
那
make_pizza()是一种方法,但你提到它作为属性?你是把它作为函数还是属性导入? -
对不起@amrs-tech 我的意思是方法。
-
尝试使用
print(dir(pizza))检查包 -
再次签出@Tomerikoo先生
标签: python-3.x error-handling attributeerror