我正在编写一个程序,它将许多数字相除,我想检查数字是否为小数。我还想让它打印那些小数。elif foo has no decimals: # (another example)
print("It has no decimals") 编辑:好的,既然“检查后面是哪个小数”带来了一些困惑我希望能够检查一个数字是否有小数。例如,7/3 (foo)给了我小数,但我想让python告诉我这一点,而不需要我
简单除法的结果,-34.11/2返回-17.055,有没有一个python函数可以返回小数的四舍五入?我期待着见到-17.06 是的,我检查了这些答案,但都不能回答这个问题:Round up to Second Decimal Place in Python How to round to nearestdecimal in Python Increment a Python floating point value by the smallest possible amoun