安装
pip install price-parser
requires Python 3.6+.
# -*- coding: utf-8 -*- from price_parser import parse_price price = parse_price('23.1$') print(price) # Price(amount=Decimal('23.1'), currency='$') price = parse_price('23,331元') print(price) # Price(amount=Decimal('23331'), currency=None) price = parse_price('23,331¥') print(price) # Price(amount=Decimal('23331'), currency='¥') print(price.amount) # 23331