Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一个数字,2122.6我想检查它是奇数还是偶数?我知道这通常适用于整数。我只会打印小数点后的一个数字。我只想看看最后一个数字是奇数还是偶数。
2122.6
我只打印小数点后的 1 位数字,所以重要的是该数字是否是 2 的倍数。[OP的评论]
这将您的问题简化到可以解决的程度:
int(x * 10) % 2 == 0 # even