Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - There was a small problem when I first learned python: the int () text of base 10 was invalid:
There was a small problem when I first learned python: the int () text of base 10 was invalid:
The direct cause of the exception is that for floating-point characters ('12.3'), int is directly used to force type conversion:

& gt& gt& gtint(' 1.5 ')

ValueError: Invalid text of int () with cardinality 10: "1.5" > & gt& gtint(' 1.0 ')

ValueError: Invalid text of int () with cardinality 10: "1.0"1234.

That is, when using int to perform forced type conversion on data of character type, it is required that the input character type can only be integer, not floating-point number.

If you must enter integer floating-point numbers together, you can do the following.

a=float(input())

In this way, whether you enter an integer or a floating-point number, you can pass. However, remembering other characters, such as abc, still won't do!