小编aaa*_*aaa的帖子

().is_integer()不起作用

这段代码有什么问题:

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)

python integer python-2.7

4
推荐指数
3
解决办法
2万
查看次数

关于python函数不确定

我只是开始并对此功能感到生气(它给了我错误的输出):

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)

另外,如何确保为"天"输入一个数字?

python python-2.7

0
推荐指数
1
解决办法
114
查看次数

标签 统计

python ×2

python-2.7 ×2

integer ×1