MONEY类
| 559 | |
| 560 | |
| 561 | class Money: |
| 562 | """ |
| 563 | MONEY类 |
| 564 | """ |
| 565 | |
| 566 | def __init__(self, money=None, chntext=None): |
| 567 | self.money = money |
| 568 | self.chntext = chntext |
| 569 | |
| 570 | # def chntext2money(self): |
| 571 | # return self.money |
| 572 | |
| 573 | def money2chntext(self): |
| 574 | money = self.money |
| 575 | pattern = re.compile(r'(\d+(\.\d+)?)') |
| 576 | matchers = pattern.findall(money) |
| 577 | if matchers: |
| 578 | for matcher in matchers: |
| 579 | money = money.replace(matcher[0], Cardinal(cardinal=matcher[0]).cardinal2chntext()) |
| 580 | self.chntext = money |
| 581 | return self.chntext |
| 582 | |
| 583 | |
| 584 | class Percentage: |