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.9.tar.gz
(159.0 kB
view hashes)
Built Distributions
sxtwl-1.0.9-cp38-cp38-win_amd64.whl
(193.4 kB
view hashes)
sxtwl-1.0.9-cp38-cp38-win32.whl
(172.1 kB
view hashes)
sxtwl-1.0.9-cp37-cp37m-win_amd64.whl
(193.3 kB
view hashes)
sxtwl-1.0.9-cp37-cp37m-win32.whl
(172.1 kB
view hashes)
sxtwl-1.0.9-cp36-cp36m-win_amd64.whl
(193.3 kB
view hashes)
sxtwl-1.0.9-cp36-cp36m-win32.whl
(172.1 kB
view hashes)
sxtwl-1.0.9-cp35-cp35m-win_amd64.whl
(193.3 kB
view hashes)
sxtwl-1.0.9-cp35-cp35m-win32.whl
(172.1 kB
view hashes)
sxtwl-1.0.9-cp34-cp34m-win_amd64.whl
(194.3 kB
view hashes)
sxtwl-1.0.9-cp34-cp34m-win32.whl
(170.8 kB
view hashes)
sxtwl-1.0.9-cp33-cp33m-win_amd64.whl
(195.0 kB
view hashes)
sxtwl-1.0.9-cp33-cp33m-win32.whl
(171.6 kB
view hashes)
sxtwl-1.0.9-cp27-cp27m-win_amd64.whl
(196.9 kB
view hashes)
sxtwl-1.0.9-cp27-cp27m-win32.whl
(173.1 kB
view hashes)
Close
Hashes for sxtwl-1.0.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8760c6b86c24193e77241a2e7021ce9e19c81559309f5991cd8f924cf6326b76 |
|
MD5 | 13742f7f3bd994de0480bf19b1208211 |
|
BLAKE2b-256 | f20960db9420a8e1e29ca90988b19f3f56b21577c8d12c94eabd041a85ac3587 |
Close
Hashes for sxtwl-1.0.9-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1876a475e569ba2f23d3101b8f720fdf636f4a307e42521f0f3423b03c333b43 |
|
MD5 | 4a4404106824e1eb4b6e4d98685022f2 |
|
BLAKE2b-256 | a2aac77fad6cce97c19f771db6f39df2f6bfd9c863dcf5afc71c799b698ed70a |
Close
Hashes for sxtwl-1.0.9-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b64c0dbab08c3332bbf5eb9de8647b9b802a250deb8c18f2ed0221069690bef |
|
MD5 | c3096badbf18ae75a12fbe28dfdbaf9b |
|
BLAKE2b-256 | e1298c913416aea64230da4e5b9444c7b863a83396457f383f648d20198121a3 |
Close
Hashes for sxtwl-1.0.9-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c16ea44cbf0053156770713c7276d2b574f575574cc3ac6b7f7954f914576b85 |
|
MD5 | 77b7366a44e71ed98699f5e425e3ed59 |
|
BLAKE2b-256 | 7583e4297cc73173a68b28c44a2a0fdd51f8e3b81afb5e66787cabf13b77ae01 |
Close
Hashes for sxtwl-1.0.9-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e89f8fae58f47df2231cb5bfffec238f92c5ec103b9c08e8ea85c197e486e75 |
|
MD5 | c678a47454c66a88033ad539c5f98734 |
|
BLAKE2b-256 | b66a332f3c662883d5013e34cbf9a59d551323b6dd4fe357ce686206f536b6d3 |
Close
Hashes for sxtwl-1.0.9-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dc6bb96b5406435883daf442123a3b088c71651ca04e3beb95d0128ac147358 |
|
MD5 | 54af517b1d93c1b163d2cc1748fb0938 |
|
BLAKE2b-256 | 4adc0116c16175a8207bd0c956666b095886334c434d2152c8e3fbe06a08ceed |
Close
Hashes for sxtwl-1.0.9-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2ce0249a3baaca7d4de05b00c63c24adddcd38a2fb2571f3efbf6e3a49c3ab6 |
|
MD5 | 6fd9e529fcea0e0595dc28631aa524dd |
|
BLAKE2b-256 | e8625663632346e6b525b7b49d94b6e2f5ebcb32f8d7b27bd1e2a4de36e49bd6 |
Close
Hashes for sxtwl-1.0.9-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b53b108fbf95227c53f8bd016d40369eab832099cd16b2a196d7868557263b8 |
|
MD5 | e8d0dd786d79ff3612697103896016d3 |
|
BLAKE2b-256 | 718573adf3de51691cfac0b6d28934bfeeab38d2ab08589fb983a945c39df59d |
Close
Hashes for sxtwl-1.0.9-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a74b2b556a493b763a6e0706ab84207947ee5d4c12d6720439a8ffe9eeb329f4 |
|
MD5 | 770fec9a4a8422912d56dd51776f50c7 |
|
BLAKE2b-256 | f69255e5942c4abef5e877815a13f818e09dcb409303e45d3617674899c8e05b |
Close
Hashes for sxtwl-1.0.9-cp33-cp33m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f23593d60d12f925d5e935b1d6747fcaca84dec720b5023117bbdb1a83e138ff |
|
MD5 | 62aa749cae156a6a047747df12600e66 |
|
BLAKE2b-256 | f3de93268028378ef8ab60ee66314a5b43beab9f2e425b31a27019f925a88c61 |
Close
Hashes for sxtwl-1.0.9-cp33-cp33m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2f503f306bb65a7cac7aa0da7f2c66f9371c91d6e52ac54c835a2ddfb722b26 |
|
MD5 | c95285f2f83212e62321e36985f6ce9a |
|
BLAKE2b-256 | 6355e353e2e6816d8b9e2db1e6e5a0ba4c2ead4e8ab240bbd64cebdb2185901c |
Close
Hashes for sxtwl-1.0.9-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a5119e9f922c10e7e35058b6280df0159e3652977e58b29dc393947d2df6be7 |
|
MD5 | 1d0d974f514f6329fe9aaa7670627e47 |
|
BLAKE2b-256 | 0166f549c668fb58ed3e9890214b60f52b369c0c4577ed733400326c57c4d40a |
Close
Hashes for sxtwl-1.0.9-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e91fcd66038c094ad7b5bcc64908dc60a5076745b61c1e566544eecd522fe853 |
|
MD5 | 1172bd9585922b4eb74b2926568b79f2 |
|
BLAKE2b-256 | 51c9a930f914be902da9c4f821b979f14509073c8f66d34fdf77e20e60ceac38 |