pythonstring-conversion

Python parse comma-separated number into int


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


Solution

  • >>> a = '1,000,000'
    >>> int(a.replace(',', ''))
    1000000
    >>>