这段代码有什么问题:
n = 10
((n/3)).is_integer()
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我不能设置n =任何数字并检查它是否是整数.
谢谢你的帮助!
python 2.7.4
错误:
Traceback (most recent call last):
File "/home/userh/Arbeitsfläche/übung.py", line 2, in <module>
print ((n/3)).is_integer()
AttributeError: 'int' object has no attribute 'is_integer'
Run Code Online (Sandbox Code Playgroud) 我只是开始并对此功能感到生气(它给了我错误的输出):
def rental_car_cost(days):
x = 40
if days < 2:
return days*x
elif days >= 3:
return days*x-20
elif days>= 7:
return days*x-50
else:
print "Please enter nr of days"
Run Code Online (Sandbox Code Playgroud)
另外,如何确保为"天"输入一个数字?