📄 moneyfmt.py
字号:
from operator import add
class MoneyFmt(float):
def __str__(self):
return "%.2f" % self
def __add__(self, other):
return MoneyFmt(float(self) + float(other))
def __iadd__(self, other):
self = MoneyFmt(float(self) + float(other))
return self
m1 = MoneyFmt(4.2562)
m2 = MoneyFmt(2.4535)
m3 = m1 + m2
print m3
m1 += m3
print type(m3)
print repr(m1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -