BoraxPython 3 開發(fā)工具集合
Borax 是一個(gè)Python3開發(fā)工具集合,包含了常用的數(shù)據(jù)結(jié)構(gòu)和設(shè)計(jì)模式。
____ | __ ) ___ _ __ __ ___ __ | _ \ / _ \| '__/ _` \ \/ / | |_) | (_) | | | (_| |> < |____/ \___/|_| \__,_/_/\_\
模塊
包括了以下模塊:
-
中國農(nóng)歷日期 borax.calendars.lunardate
-
國際/國內(nèi)節(jié)日 borax.calendars.festivals
-
樹形數(shù)據(jù)結(jié)構(gòu) borax.structures.tree
-
單例模式 borax.patterns.singleton
-
代理模式 borax.patterns.lazy
-
json序列化 borax.serialize.bjson / borax.serialize.cjson
-
財(cái)務(wù)金額格式化 borax.finance
-
別名字典、屬性字典 borax.dictionary
-
列表常用函數(shù) borax.utils
使用示例
農(nóng)歷日期
>>>from borax.calendars.lunardate import LunarDate, LCalendars >>>LunarDate(2018, 7, 1) LunarDate(2018, 7, 1, 0) >>>ld = LunarDate.from_solar_date(2018, 8, 11) >>>ld LunarDate(2018, 7, 1, 0) >>>LCalendars.ndays(2018) 354 >>>LCalendars.ndays(2018, 12) 30 >>>LCalendars.ndays(2017, 6, 1) 30
金額大寫
>>> from borax.finance import financial_amount_capital >>> financial_amount_capital(100000000) '壹億元整' >>>financial_amount_capital(4578442.23) '肆佰伍拾柒萬捌仟肆佰肆拾貳元貳角叁分' >>>financial_amount_capital(107000.53) 壹拾萬柒仟元伍角叁分
字段選取
from borax.fetch import fetch
objects = [
{'id': 282, 'name': 'Alice', 'age': 30},
{'id': 217, 'name': 'Bob', 'age': 56},
{'id': 328, 'name': 'Charlie', 'age': 56},
]
names = fetch(objects, 'name')
print(names)
更多示例查看 https://kinegratii.github.io/borax
評(píng)論
圖片
表情
