gpt4 book ai didi

python - 为什么返回 Nonetype?

转载 作者:行者123 更新时间:2023-11-30 22:49:23 25 4
gpt4 key购买 nike

我对 Python 还很陌生。我正在制作一个生成器,可以为面包店估算举办一场事件(如果他们制作纸杯蛋糕)所需的费用。不过这里出了点问题

Batches = print("Batches of Cupcakes:", math.ceil(People * Ingredients / 12))

Labor = print("Hours of labor:", Batches * 1.25)

我收到此错误:

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

最佳答案

因为 print 总是返回 None。您想将先前的结果保存在变量中:

batches = math.ceil(people * ingredients/12)
labor = batches * 1.25

print("Batches of cupcakes:", batches)
print("Hours of labor:", labor)

关于python - 为什么返回 Nonetype?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39802548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com