Python编程:使用money对货币进行计算

版权声明:本文为博主原创文章,欢迎转载,请注明出处 https://blog.csdn.net/mouday/article/details/84822927

money模块对货币进行简单的包装,实现简单的货币计算
安装

pip install money

代码示例

from money import Money

m1 = Money("2.0", "RMB")
print(m1)  # RMB 2.00
print(m1.amount)  # 2.0
print(m1.currency)  # RMB

m2 = Money("1.0", "RMB")
print(m1 + m2)
# RMB 3.00

项目地址:https://github.com/carlospalol/money

没有更多推荐了,返回首页