Valueerror: Invalid Literal For Int() With Base 10: '' Python
ValueError: invalid literal for int() with base 10: '' Why it showing the error of int(), in fact the values coming from the cgi is as string which i am converting it to integer, b
Solution 1:
The problem is because int
tries to convert ''
to a base 10 number, which is not possible. Thats why it is failing. You are getting the default ''
if the value is not there like this
form.getvalue('opt_12', '')
instead of that use a sentinel value like this
form.getvalue('opt_12', '0')
Even better, you can convert them to numbers as and when you get them from the form like this
res12 = int(form.getvalue('opt_12', '0'))
.........
Post a Comment for "Valueerror: Invalid Literal For Int() With Base 10: '' Python"