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.
如何在 Python 3 中截断小数点后的所有数字?
例如,将 3.444 截断为 3。
通过将其转换为int:
int
>>> num = 3.444 >>> int(num) 3
>>> import math >>> num = 3.4444 >>> math.trunc(num) 3