string-conversion

Python parse comma-separated number into int

Python parse comma-separated number into int Question: How would I parse the string 1,000,000 (one million) into it’s integer value in Python? Asked By: roryf || Source Answers: >>> a = ‘1,000,000’ >>> int(a.replace(‘,’, ”)) 1000000 >>> Answered By: joaquin Replace the ‘,’ with ” and then cast the whole thing to an integer. >>> …

Total answers: 3