使用if num-int(num)==0:
num_list=[1,2.0,1.0,2.63]
for num in num_list:
if num-int(num)==0:
print(num)
运行结果
E:\Python\Python38\python.exe D:/pythonprojects/python-auto-test/test/temp.py
1
2.0
1.0
Process finished with exit code 0