gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 08:21:40 25 4
gpt4 key购买 nike

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com