Python decimals are converted into int integers, why must they be converted into floats first?

When doing exercises, I suddenly encountered a problem that I did not encounter when learning the basics of python: that is, when converting decimals into integers, they need to be converted into float types first.

 why? (Small head, big doubts?)

Then in the comments, someone asked the same question as me, and someone replied below:

 Then I just recompiled my code:

num=float(input())
print(int(num))

Then it worked!

This is a knowledge point that has never been encountered before, and it is now get✅ 

Guess you like

Origin blog.csdn.net/qq_55482452/article/details/126871711