sxtwl_cpp warpper for python
Project description
安装方法
pip install sxtwl
使用方法
- 因为考虑到繁体和简体字的原因,所以本库不以硬编码的形式显示结果。下面是参考的简单索引
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
ShX = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"]
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ]
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
- 引入本库
import sxtwl
lunar = sxtwl.Lunar() #实例化日历库
#下面可以使用lunar做些日历的操作
- 获取某天的信息(这里的信息有,阴历,阳历,二十四节气,天干地支,星期几等)
- 通过阳历获取查询日期信息
day = lunar.getDayBySolar(2018, 10, 20) # 查询2018年10月20日
- 通过阴历获取查询日期信息
day = lunar.getDayByLunar(2018, 10, 20 , False) #查询阴历2018年10月20日的信息,最后一个False表示是否是润月,填True的时候只有当年有润月的时候才生效
或
day = lunar.getDayByLunar(2018, 10, 20 )
- 处理你的日历信息(比如实现阴历转阴历,阳历转阴历)
print("公历:", day.y, "年", day.m, "月", day.d, "日")
if day.Lleap:
print("润", ymc[day.Lmc], "月", rmc[day.Ldi], "日")
else:
print(ymc[day.Lmc], "月", rmc[day.Ldi], "日")
print("儒略日:JD", sxtwl.J2000 + day.d0)
print("星期", numCn[day.week])
print(Gan[day.Lyear2.tg], Zhi[day.Lyear2.dz], "年", Gan[day.Lmonth2.tg], Zhi[day.Lmonth2.dz], "月",\
Gan[day.Lday2.tg], Zhi[day.Lday2.dz], "日")
print("距冬至", day.cur_dz, "天")
print("距夏至", day.cur_xz, "天")
print("距立秋", day.cur_lq, "天")
print("距芒种", day.cur_mz, "天")
print("距小暑", day.cur_xs, "天")
获取月历信息
import sxtwl
import sys
type = sys.getfilesystemencoding()
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
ShX = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"]
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ]
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]
month = sxtwl.Lunar().yueLiCalc(2017, 12)
#打印做一个中间转换
def log(*arg):
s = ""
for v in arg:
s += str(v)
print(s.decode('UTF-8').encode(type))
log(month.y, "年", month.m, "月")
log(Gan[month.yearGan], Zhi[month.yearZhi], "年")
log("生肖:", ShX[month.ShX])
days = month.days
J2000 = 2451545
for day in days:
log("===================================================")
log("公历:", day.y, "年", day.m, "月", day.d, "日")
if day.Lleap:
log("润", ymc[day.Lmc], "月", rmc[day.Ldi], "日")
else:
log(ymc[day.Lmc], "月", rmc[day.Ldi], "日")
log("儒略日:JD", sxtwl.J2000 + day.d0)
log("星期", numCn[day.week])
log(Gan[day.Lyear2.tg], Zhi[day.Lyear2.dz], "年", Gan[day.Lmonth2.tg], Zhi[day.Lmonth2.dz], "月",\
Gan[day.Lday2.tg], Zhi[day.Lday2.dz], "日")
log("距冬至", day.cur_dz, "天")
log("距夏至", day.cur_xz, "天")
log("距立秋", day.cur_lq, "天")
log("距芒种", day.cur_mz, "天")
log("距小暑", day.cur_xs, "天")
如果您是一个命理学爱好者,还提供二条接口
#获取八字时辰的天干地支
gz = lunar.getShiGz(2, 12) #第一个参数为生日的日天干,参数二为出生的时间(小时)
print( Gan[gz.tg], Zhi[gz.dz])
#获取一年的信息
year = lunar.getYearCal(2018)
懒人安装包下载地址 (只提供Win版本):
https://pan.baidu.com/s/1VR4MtPVV9iP9SSHNDjKZnQ
交流沟通群
如果在使用过程中遇到困难,可加微信群(如二维码过期,邮件:lifulinghan@aol.com索要新的):
最后
- 如果想加入此项目请联系 元谷(lifulinghan@aol.com)
- 如果使用此项目,请告之一下作者
- 如果您使用了此项目的代码,为了表示对寿星天文历原作者的尊重,请您项目适当的位置表达对许剑伟先生感谢
- 如果你觉得本库不错,欢迎打赏作者
微信用户打赏入口:
支付宝用户打赏入口:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sxtwl-1.0.8.tar.gz
(160.9 kB
view hashes)
Built Distributions
sxtwl-1.0.8-cp38-cp38-win_amd64.whl
(187.2 kB
view hashes)
sxtwl-1.0.8-cp38-cp38-win32.whl
(172.4 kB
view hashes)
sxtwl-1.0.8-cp37-cp37m-win_amd64.whl
(187.1 kB
view hashes)
sxtwl-1.0.8-cp37-cp37m-win32.whl
(172.3 kB
view hashes)
sxtwl-1.0.8-cp36-cp36m-win_amd64.whl
(187.1 kB
view hashes)
sxtwl-1.0.8-cp36-cp36m-win32.whl
(172.3 kB
view hashes)
sxtwl-1.0.8-cp35-cp35m-win_amd64.whl
(187.0 kB
view hashes)
sxtwl-1.0.8-cp35-cp35m-win32.whl
(172.3 kB
view hashes)
sxtwl-1.0.8-cp34-cp34m-win_amd64.whl
(188.9 kB
view hashes)
sxtwl-1.0.8-cp34-cp34m-win32.whl
(171.5 kB
view hashes)
sxtwl-1.0.8-cp33-cp33m-win_amd64.whl
(189.7 kB
view hashes)
sxtwl-1.0.8-cp33-cp33m-win32.whl
(172.2 kB
view hashes)
sxtwl-1.0.8-cp27-cp27m-win_amd64.whl
(191.7 kB
view hashes)
sxtwl-1.0.8-cp27-cp27m-win32.whl
(173.7 kB
view hashes)
Close
Hashes for sxtwl-1.0.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c0aa84e9fcecf117e454087f3f757e0d09dcc556b290bc9851a24e0a8aec8fc |
|
MD5 | 3f2cd4999b1552e7d94724d5cf851a2f |
|
BLAKE2b-256 | 3b400d788af57c532912f6798b9ecd03a1e9ec8cafd3250cad7ff19e495a1d8b |
Close
Hashes for sxtwl-1.0.8-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23e31c2235205e3a6b66bdd4c1e99a01e7c02c7623c8f56393eb15a4497f0b4f |
|
MD5 | 15ba06784e6f326870d88fc8f05f52be |
|
BLAKE2b-256 | 948711e690f5d971156097fb3c959ec25df01bb800cbd69015b9f3f995de0629 |
Close
Hashes for sxtwl-1.0.8-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 043d89f166406f7f59b93112f7ef7cfebc345751326b0f19ea1dc7bda4dda36d |
|
MD5 | b5252c72bd796206c92536e45048dc26 |
|
BLAKE2b-256 | 61ba4c7d929471ba8c6379515a7771e78b239b68c4da5e26cfd5c45debe87228 |
Close
Hashes for sxtwl-1.0.8-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53ef092ccbc49699afeedab52879105bc8f9fd5521d13f5e059221588061b474 |
|
MD5 | e42b7ec29d22a529654c56db7f5e2033 |
|
BLAKE2b-256 | 17c8aacce53806d0adb029cdda4f5502b80f53c2f4bdf30d61e5927870e5c6a9 |
Close
Hashes for sxtwl-1.0.8-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3492fd4163fe931f537af01d31102c5b93cb75d2ce37f803c355237999781e20 |
|
MD5 | 4954f96c111316e44e178cbd43794ac1 |
|
BLAKE2b-256 | aa44faf22b3749d2fd5f7a9a04345e54d8aa8301e48516dc23568cee953d09d6 |
Close
Hashes for sxtwl-1.0.8-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb15a351e89a984345b4625647c8c94c31a8547a6e6107c39da5bd2412fd3401 |
|
MD5 | 85d877653dd2ea8f87546670a71342a2 |
|
BLAKE2b-256 | 9392ec84bf94bdeeeae3e80c818e7d8c86e8b6a10cb753df1090780dc29f17aa |
Close
Hashes for sxtwl-1.0.8-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 697c4428e4d64fe3f571d9bec87dd552ec70e76245b35c8d3091289a18dfbf9c |
|
MD5 | 9413e7883379019d969105f182ef667c |
|
BLAKE2b-256 | 12a8efde8dc0791db5994f08dee4f525298854d7aabc4c869d210b6d95b7e70c |
Close
Hashes for sxtwl-1.0.8-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce72082e8c370d5f5a1765de50ace328c42bb49c469be64de5e321fbf1059a9 |
|
MD5 | 3d2eddb9cdd55e4a12d19f1772965af7 |
|
BLAKE2b-256 | e68417780006a77f44f4cf942e8a2ac53d12dd93820a113a7df1e37be12a530f |
Close
Hashes for sxtwl-1.0.8-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54d11256f3ccca9098966c020e51842a5845eae15cd03c4e3557be82f4d0e1d6 |
|
MD5 | e000af52e73a93cf6454f914b7e20eca |
|
BLAKE2b-256 | 901ab6ed927b4de97127245574e0a2c9e2eb35e8bfed567fe0842dd8e4228588 |
Close
Hashes for sxtwl-1.0.8-cp33-cp33m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90412236028746d94ffa8bcf31d12612e803832ae5ba0f8865cf61febb83ee2a |
|
MD5 | 36b5fa2617aa197d1fad74cef5bb282e |
|
BLAKE2b-256 | 100da8b64e28b864a958b6cc467cdd30acc6b3be84faf35f723a1251f8b4b712 |
Close
Hashes for sxtwl-1.0.8-cp33-cp33m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f39d077d3aa643686ce5ff0409971dae636558cd233d296e2001b84bc991eda2 |
|
MD5 | 03d8142ba9c8aa93e3104a2cb4c9e2a1 |
|
BLAKE2b-256 | d6af855cbbb59b1ecf09367eb396361bdb865d125f477e168c06845fe71c01c6 |
Close
Hashes for sxtwl-1.0.8-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45866cb3893cbe31987ea5af71a05352ed9cb6ccf8e41433121ec7416fed835 |
|
MD5 | 367ae3af5a39a932d037beb57e062e49 |
|
BLAKE2b-256 | 767a70a69441c174505bc6e0a9f4d64acaf0fa59f5d7a9a1d70fdd1098a82db8 |
Close
Hashes for sxtwl-1.0.8-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24d0707a4120b4d84d9b99b3a84eaa181c78a2753aa843261c5185580e8b1ecf |
|
MD5 | ab36b25c3df587c9bc57f687272a8648 |
|
BLAKE2b-256 | 5f4303480ed5b5073ea20524bfc0168e0bb6ee6c2490d470a15f4f9b8ea092c6 |