How to convert Euro currency string to float number?

前端 未结 4 469
滥情空心
滥情空心 2020-12-22 02:44

I need to convert a string currency string in Continental Europe format into a float number:

Input:

\'6.150.593,22 €\'

Realize tha

4条回答
  •  無奈伤痛
    2020-12-22 03:29

    A simple solution may be as follows:

    >>> val = '6.150.593,22 €'
    >>> res = val[:-2].split(',')
    >>> float('.'.join([res[0].replace('.', ''), res[1]]))
    6150593.22
    

提交回复
热议问题