Python parse comma-separated number into int

roryf picture roryf · Jun 2, 2010 · Viewed 86.3k times · Source

Possible Duplicate:
How do I use Python to convert a string to a number if it has commas in it as thousands separators?

How would I parse the string 1,000,000 (one million) into it's integer value in Python?

Answer

joaquin picture joaquin · Jun 2, 2010
>>> a = '1,000,000'
>>> int(a.replace(',', ''))
1000000
>>>