【发布时间】:2018-06-28 01:05:01
【问题描述】:
def monthly_gas_cost(days,miles,mpg,gas_cost):
return '${} A month for gas'.format(miles/mpg*days*gas_cost)
我在python中做了一个简单的函数,刚刚使用python没有思考,它已经与
print(monthly_gas_cost(days=23,miles=4,mpg=30,gas_cost=2.87))
但是当我尝试下面的行时,它只使用 python 3 进行计算。使用 python 2 它不计算。
print(monthly_gas_cost(days=23,miles=12,mpg=20,gas_cost=2.87))
【问题讨论】:
-
"它只适用于 python 3" --- 这到底是什么意思?在python 2.7下运行你的电脑会关机吗?
-
@zerkms 没有完成计算
-
“没有完成计算”的意思是“永远冻结”,而你观察到的东西肯定不同。清楚地解释问题也有助于您从一开始就理解问题。
标签: python-3.x python-2.7 function