Cmag Cmag - 1 day ago 3
Python Question

Converting string to integer with python

When trying to convert a string into integer to be used as a variable later in the code, I get the following:

print int(urlsuccessful[i])

ValueError: invalid literal for int() with base 10: '2,919,247'

Answer

If only problems are commas, try:

>>> int("2,919,247".replace(",", ""))
2919247
Comments