假设我有一个文件如下:
项目0\pizza.py
项目0\make_pizza.py
还有披萨:

def make_pizza(size,*toppings):
print("\nMaking a " + str(size)
      + "-inch pizza with the following toppings:")
for topping in toppings:
    print("- " + topping)

做比萨:
from pizza import make_pizza
pizza.make_pizza(16, 'pepperoni')

如代码所示,我希望import pizza进入make_pizza,但是ide显示了一个错误,即没有名为pizza的模块。如何解决此问题并将pizza导入make_pizza

最佳答案

您正确地导入了它,但您的调用不正确。
正确的称呼是:

make_pizza(16, 'pepperoni')

10-05 18:21