Cmag Cmag - 1 year ago 108
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 Source

If only problems are commas, try:

>>> int("2,919,247".replace(",", ""))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download