python - 如何检查整数小数点后的值是否为零

标签 python integer

如何判断整数小数点后是否为零

a = 17.3678

if a???:
  print("the value after the decimal point is zero")
else:
  print("the value after the decimal point is not zero")

最佳答案

可以使用split方法:

a = 17.3678
a = str(a)
valueAfterPoint = a.split('.')[1]
valueAfterPoint = int(valueAfterPoint)

if valueAfterPoint == 0:
  print("the value after the decimal point is zero")
else:
  print("the value after the decimal point is not zero")

关于python - 如何检查整数小数点后的值是否为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71372380/

相关文章:

python - 如何将字符串格式作为变量传递给 f 字符串

python - 在函数外部用 cdef 声明的变量在函数内部是否具有相同的类型?

c# - 在 c# 中,我想在每次另一个整数增加一定数量时增加一个整数

types - 什么是定点整数?

c - 用于保存函数指针的整数类型?

python - 在 python csv 文件中写一个列表,每个列表一个新行

python - 如何使用 Docker 创建 Python 可执行文件

c - C 中函数返回的整数值

c++ - 如何将 C++ 数字格式设置为一定的精度?

python - 使用 python 评估滤波器 matlab 函数