joh*_*per 15 python python-2.x
我想确定Python中的数值是否是整数.例如,给定:
y = x / 3
Run Code Online (Sandbox Code Playgroud)
我想区分x
其中的值可被3整除的值.
Art*_*par 62
整数没有小数.如果你的意思是"检查数字是否在Python中有小数",你可以这样做:
not float(your_number).is_integer()
Run Code Online (Sandbox Code Playgroud)
int*_*jay 24
if x % 3 == 0:
print 'x is divisible by 3'
Run Code Online (Sandbox Code Playgroud)