ValueError: Invalid literal for base 10 int(): ''
P粉022501495
P粉022501495 2024-03-25 15:34:49
0
1
624

I'm getting this error in my code:

ValueError: invalid literal for int() with base 10: ''.

What does it mean? Why does this happen and how to solve it?

P粉022501495
P粉022501495

reply all(1)
P粉578343994

This error message means that the string supplied to int cannot be parsed as an integer. The last part after : displays the provided string.

In the case of the problem description, the input is an empty string , written as ''.

Here's another example - strings representing floating point values ​​cannot be converted directly with int:

>>> int('55063.000000')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: '55063.000000'

Instead, first convert to float:

>>> int(float('55063.000000'))
55063
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template