python 安装模块+price,Python price-parser包_程序模块 - PyPI - Python中文网

支持案例

支持多种货币的不洁价格串;

处理千个分隔符和十进制分隔符:>>> Price.fromstring("Price: $119.00")

Price(amount=Decimal('119.00'), currency='$')>>> Price.fromstring("15 130 Р")

Price(amount=Decimal('15130'), currency='Р')>>> Price.fromstring("151,200 تومان")

Price(amount=Decimal('151200'), currency='تومان')>>> Price.fromstring("Rp 1.550.000")

Price(amount=Decimal('1550000'), currency='Rp')>>> Price.fromstring("Běžná cena 75 990,00 Kč")

Price(amount=Decimal('75990.00'), currency='Kč')

欧元符号用作任意小数点分隔符:>>> Price.fromstring("1,235€ 99")

Price(amount=Decimal('1235.99'), currency='€')>>> Price.fromstring("99 € 95 €")

Price(amount=Decimal('99'), currency='€')>>> Price.fromstring("35€ 999")

Price(amount=Decimal('35'), currency='€')

处理一些特殊情况:>>> Price.fromstring("Free")

Price(amount=Decimal('0'), currency=None)

当无法提取价格或货币时,对应

属性值设置为无:>>> Price.fromstring("")

Price(amount=None, currency=None)>>> Price.fromstring("Foo")

Price(amount=None, currency=None)>>> Price.fromstring("50% OFF")

Price(amount=None, currency=None)>>> Price.fromstring("50")

Price(amount=Decimal('50'), currency=None)>>> Price.fromstring("R$")

Price(amount=None, currency='R$')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值