python int( ) function

前端 未结 5 1773
逝去的感伤
逝去的感伤 2021-02-15 13:06

The code below shows error if a decimal (eg. 49.9) is sent to next variable. Can you please tell me why? Why does int() converts it into an in

5条回答
  •  孤独总比滥情好
    2021-02-15 13:36

    int() only works for strings that look like integers; it will fail for strings that look like floats. Use float() instead.

提交回复
热议问题