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.1.0.tar.gz
(164.8 kB
view hashes)
Built Distributions
sxtwl-1.1.0-cp38-cp38-win_amd64.whl
(210.0 kB
view hashes)
sxtwl-1.1.0-cp38-cp38-win32.whl
(183.4 kB
view hashes)
sxtwl-1.1.0-cp37-cp37m-win_amd64.whl
(210.2 kB
view hashes)
sxtwl-1.1.0-cp37-cp37m-win32.whl
(183.5 kB
view hashes)
sxtwl-1.1.0-cp36-cp36m-win_amd64.whl
(210.2 kB
view hashes)
sxtwl-1.1.0-cp36-cp36m-win32.whl
(183.5 kB
view hashes)
sxtwl-1.1.0-cp35-cp35m-win_amd64.whl
(210.2 kB
view hashes)
sxtwl-1.1.0-cp35-cp35m-win32.whl
(183.5 kB
view hashes)
sxtwl-1.1.0-cp34-cp34m-win_amd64.whl
(211.4 kB
view hashes)
sxtwl-1.1.0-cp34-cp34m-win32.whl
(183.5 kB
view hashes)
sxtwl-1.1.0-cp33-cp33m-win_amd64.whl
(212.3 kB
view hashes)
sxtwl-1.1.0-cp33-cp33m-win32.whl
(184.2 kB
view hashes)
sxtwl-1.1.0-cp27-cp27m-win_amd64.whl
(214.3 kB
view hashes)
sxtwl-1.1.0-cp27-cp27m-win32.whl
(186.0 kB
view hashes)
Close
Hashes for sxtwl-1.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5376c8a5f751314e65715f3af189906ad6ab6e5b34b0c28a5084559b3389d782 |
|
MD5 | 8803eb36a09c9202f0a87c5a8693156f |
|
BLAKE2b-256 | a1a4cf2ba5309c3cb8daff049c484cba3f3f7c8c14318b9bda916e9f5fbb46c8 |
Close
Hashes for sxtwl-1.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b60d677fb705f65b9111532654daf3ce3276c2d9f4d8241ab266bb41fc797809 |
|
MD5 | 99085d3dcad83dbf2b38093d1aa3ad8e |
|
BLAKE2b-256 | a770608a1cb0b304c1601ab282b37458c0c408c23307c59c00c24c7d6c07d00c |
Close
Hashes for sxtwl-1.1.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 387403e53f9a78c0bd80b3e95193f5f76bc302a9aa891d0e151061286ab8fdd5 |
|
MD5 | 8a6e770c92cb00eff9a13fa580286e5d |
|
BLAKE2b-256 | cd0bf222891210de0fc32e745f4967593b1d8e7c326107753a95795091bdf70d |
Close
Hashes for sxtwl-1.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33383c1876d81d7d419acc7ba4dd7e6e95e96ac9f5251d182748ba1596233893 |
|
MD5 | 38e39725c9bde979bc2f0c294444729b |
|
BLAKE2b-256 | 0c34ee390fc66bf0805d95936a4306e5da76da60bda3b8247ec9bd93a972cd29 |
Close
Hashes for sxtwl-1.1.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a54a3a6a5906e9dd4eef3976c45596109ad538ceddab810d299a1157e046d23e |
|
MD5 | d48d2799db2be800dce215e35617a8e0 |
|
BLAKE2b-256 | d877d3da6b124eaaa18ec809703c5a2e9dc82354a5f62ce2c34dcf85d61221bc |
Close
Hashes for sxtwl-1.1.0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 529dc6200c914ac947f53a01ec381a4d75550bcf645ccaeac71cd5033aa89805 |
|
MD5 | 86c596f9ba3c255ad5bccc30d6351bf1 |
|
BLAKE2b-256 | bb396fe65e1d8eaa6d89f4f96dc8293ced83af133da07429cd44e453cd6b8da8 |
Close
Hashes for sxtwl-1.1.0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0bba40d12612da5e78cd36a5207a1acd43faa8ec11b8719b6f66e7e6f75b692 |
|
MD5 | 1bff35d510db8cfe29734174fc4f69f3 |
|
BLAKE2b-256 | 326ba10a790a5ce83e57db7c3637f9c20a32d75f5d56d24c8f5494b40e571e1c |
Close
Hashes for sxtwl-1.1.0-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3acdd1cf81e1cd3d009be36033d17093975263fa1667d2c1b8f9e8e49aede891 |
|
MD5 | 8a6f03209db53cc57237c8cf01e06698 |
|
BLAKE2b-256 | 2fee1fe5b03b7d4de33181ab1f2b839bc65ad0a842638db4feea6e1448144b6a |
Close
Hashes for sxtwl-1.1.0-cp34-cp34m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e90001d6a77536bc616bacd528049a46ca9d56963b560c3b776cbc6f100290fd |
|
MD5 | 356dcd8324ee3e1a66ad2321bdb151bc |
|
BLAKE2b-256 | 45de0d9ec9ee6863b466d21a332e1c6464c0d898dd65c065a54c2f4e141dad3a |
Close
Hashes for sxtwl-1.1.0-cp33-cp33m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f83faf2b9a5840cb581756df3e3a7c86d39d68f301b00007ce364cc881e5b389 |
|
MD5 | 70d321f0a5252371b76d1a8b3672873c |
|
BLAKE2b-256 | ac27ee631431dd35e7f09d9fc5ebe23a78ca54d0e3dab84c942e84e940f44f7b |
Close
Hashes for sxtwl-1.1.0-cp33-cp33m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308824d5e2c6e2e243538a509efbc7444ad496aa9e93e3de3727ce01274aa783 |
|
MD5 | 53551ce8e49fa319302053c4e659d0f4 |
|
BLAKE2b-256 | b6e194bee484d2603975eca0acdb54107d9c3f8fa7a3a1376d0bdb9fda3f7404 |
Close
Hashes for sxtwl-1.1.0-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46ec9bf25172df197d331ac63484e065641a4a12eff041090ba5dbe29abdb43a |
|
MD5 | 4e0d50c2511f3ccd1c2403d90e48fe8c |
|
BLAKE2b-256 | bea841be17368d02534ab7b5ef378f1651381421c057c2752bf7ebadbabd15c2 |
Close
Hashes for sxtwl-1.1.0-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b294b5ced4bfdf41af2eb890fc12d4096a9d732acf4d8dc01ec0b8f6e330956 |
|
MD5 | 23f6dc746a0a7924dd05e79db4775e92 |
|
BLAKE2b-256 | 5985cdcdf508070edbc5c8fcfdf14ff71a725c4f0416f32c770e2b9cc8f3b787 |