内容简介:Borax是一个Python3开发工具集合,包含了许多常用的工具、数据结构、函数封装等。 其中Borax.Calendars是农历/节日/年龄的计算工具库,功能完备,使用简单。 v1.3.0 更新日志: 修订农历日期数据,通过微软农历类...
Borax是一个 Python 3开发 工具 集合,包含了许多常用的工具、数据结构、函数封装等。
其中Borax.Calendars是农历/节日/年龄的计算工具库,功能完备,使用简单。
v1.3.0 更新日志:
- 修订农历日期数据,通过微软农历类的验证
- LunarDate、DateSchema支持对象序列化,可集成到数据库字段定义
- 支持省略年份方式的字符串表达形式
- 新增虚岁、周岁年龄的计算
使用示例
打印LunarDate的属性。
from borax.calendars.lunardate import LunarDate
ld = LunarDate(2018, 6, 26)
print(ld.term) # 立秋
print(ld.gz_year) # '戊戌'
print(ld.gz_month) # '庚申'
print(ld.gz_day) # '辛未'
print(ld.cn_str()) # '二〇一八年六月廿六'
print(ld.gz_str()) # '戊戌年庚申月辛未日'
print(ld.weekday()) # 0,星期一
节日的使用方法
from datetime import date
from borax.calendars.festivals import SolarSchema, DayLunarSchema
# 情人节的日期匹配
d = SolarSchema(month=2, day=14)
print(md.match(date(2020, 2, 14))) # True
# 计算距离除夕还有多少天
ls = DayLunarSchema(month=12, day=1, reverse=1)
print(ls.countdown()) # 326
以上所述就是小编给大家介绍的《Borax 1.3.0 发布,Python 3 开发工具集合》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Borax 3.4.1 发布,Python 开发工具集合库
- Scala 中的集合(二):集合性能比较
- Scala 中的集合(二):集合性能比较
- 《面试知识,工作可待:集合篇》:Java 集合面试知识大全
- 如何对集合对象求合计,然后追加在该集合对象中
- MongoDB指南---14、特殊的索引和集合:固定集合、TTL索引、全文本索引
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Programming in Java
Robert Sedgewick、Kevin Wayne / Addison-Wesley / 2007-7-27 / USD 89.00
By emphasizing the application of computer programming not only in success stories in the software industry but also in familiar scenarios in physical and biological science, engineering, and appli......一起来看看 《Introduction to Programming in Java》 这本书的介绍吧!