Try this:
from re import sub
from decimal import Decimal
money = '$6,150,593.22'
value = Decimal(sub(r'[^d.]', '', money))
This has some advantages since it uses Decimal
instead of float
(which is better for representing currency) and it also avoids any locale issues by not hard-coding a specific currency symbol.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…