How to convert string with commas thousand separator to float in Python

1 Answer

0 votes
import locale

s = '487,7347.19'

locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

f = locale.atof(s)

print(f)

     
     
     
'''
run:
     
4877347.19

'''

 



answered Apr 12, 2021 by avibootz
...