Skip to main content

sxtwl_cpp warpper for python

Project description

安装方法

pip install sxtwl

使用方法

  1. 因为考虑到繁体和简体字的原因,所以本库不以硬编码的形式显示结果。下面是参考的简单索引
Gan = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"]
Zhi = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"]
ShX = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
numCn = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"]
jqmc = ["冬至", "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑","白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪"]
ymc = ["十一", "十二", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十" ]
rmc = ["初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十", "卅一"]

  1. 引入本库
import  sxtwl
lunar = sxtwl.Lunar()  #实例化日历库
#下面可以使用lunar做些日历的操作
  1. 获取某天的信息(这里的信息有,阴历,阳历,二十四节气,天干地支,星期几等)
  • 通过阳历获取查询日期信息
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 )
  1. 处理你的日历信息(比如实现阴历转阴历,阳历转阴历)
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


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.7.tar.gz (155.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sxtwl-1.0.7-cp37-cp37m-win_amd64.whl (180.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

sxtwl-1.0.7-cp37-cp37m-win32.whl (166.0 kB view details)

Uploaded CPython 3.7mWindows x86

sxtwl-1.0.7-cp36-cp36m-win_amd64.whl (180.7 kB view details)

Uploaded CPython 3.6mWindows x86-64

sxtwl-1.0.7-cp36-cp36m-win32.whl (166.0 kB view details)

Uploaded CPython 3.6mWindows x86

sxtwl-1.0.7-cp35-cp35m-win_amd64.whl (180.7 kB view details)

Uploaded CPython 3.5mWindows x86-64

sxtwl-1.0.7-cp35-cp35m-win32.whl (166.0 kB view details)

Uploaded CPython 3.5mWindows x86

sxtwl-1.0.7-cp34-cp34m-win_amd64.whl (182.0 kB view details)

Uploaded CPython 3.4mWindows x86-64

sxtwl-1.0.7-cp34-cp34m-win32.whl (165.4 kB view details)

Uploaded CPython 3.4mWindows x86

sxtwl-1.0.7-cp33-cp33m-win_amd64.whl (182.7 kB view details)

Uploaded CPython 3.3mWindows x86-64

sxtwl-1.0.7-cp33-cp33m-win32.whl (166.1 kB view details)

Uploaded CPython 3.3mWindows x86

sxtwl-1.0.7-cp27-cp27m-win_amd64.whl (184.3 kB view details)

Uploaded CPython 2.7mWindows x86-64

sxtwl-1.0.7-cp27-cp27m-win32.whl (167.9 kB view details)

Uploaded CPython 2.7mWindows x86

File details

Details for the file sxtwl-1.0.7.tar.gz.

File metadata

  • Download URL: sxtwl-1.0.7.tar.gz
  • Upload date:
  • Size: 155.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7.tar.gz
Algorithm Hash digest
SHA256 2f9eb25f3835b013fe49bd854113f3f37a4fc40e30ee79212fd688fc502a16a4
MD5 9f025ee42f6a62da51f534a1d3a3da2c
BLAKE2b-256 f85e6c2c35b4de8779ad8ddc94da9bfa63ab385b5fe07a72b8cca9a272c4308d

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 180.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 9485da5426792252444bf1079dbc9c800dcfa5728d47f4fa0155b860068109ca
MD5 457a6458b2e65c55295f6004cb3846da
BLAKE2b-256 f55f628f69fa3827bec0a09a55f31ef23486d702cb463d1d9e09eb408de7ecbb

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp37-cp37m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 166.0 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 539c61198051dbde7872d5bbb6bd4cc759744400963d562dec720d70b79136b1
MD5 71190d98df76fba64a694cde58796d96
BLAKE2b-256 5aa59682a884b7addc09496bdb167a0eb1577aef92dad3ce7d475df2b733e774

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 180.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 b88e239bb76024f42767bfa5d1687c35b0f52ea9eda7f16f181f380d8ca12c34
MD5 f81fa305995a704505b91f3cdd5b88be
BLAKE2b-256 e8d0a2f7fa339539bab0b1c6bd22817606a395579137da479086b9b901076c15

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp36-cp36m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 166.0 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 d51e77752705976e28086b9c513d1db6e1a44056c68df68c2ba2356bbadc8b25
MD5 b0f8b7d13c4ec3f436f86934db27f302
BLAKE2b-256 f3f6fb8631560a90ecaa2fe886cfb72871e90dbfc1be7513805597938137c835

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 180.7 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 eed8e42cac43226ba681984f9050efd6f879d71c35dc23910395fb2ef7d89d3e
MD5 41ff73a49f9c6539b04e0506e9237e35
BLAKE2b-256 2e35d37433d53eaa1e925242511b8cdc747a1ffe846aca90fe1f573211c91d14

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp35-cp35m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 166.0 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 c9f5d9d0d340705bd9fa7d3f87dce475d532ef5e204ad5989457825d1be3192b
MD5 c9c1e2707c1dd910e463981b9a92ff99
BLAKE2b-256 0b7db8a75f52acba438ac4dbf6e80efd5b3fb7b1fc4a5207f2bbf94d9e27ba8e

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp34-cp34m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp34-cp34m-win_amd64.whl
  • Upload date:
  • Size: 182.0 kB
  • Tags: CPython 3.4m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 c67c5745561c17354d3b874baa84db6bbfa7f24fd3c941c8e2384d4cf4f98f0b
MD5 b64e6113ccbb19f51c01230d51025543
BLAKE2b-256 3faec4c82868768373614bef17fffab47539af45459f93207a529486fbbe582f

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp34-cp34m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp34-cp34m-win32.whl
  • Upload date:
  • Size: 165.4 kB
  • Tags: CPython 3.4m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 debb7e51a8008388670baa3006e83b4961288a1316d164bbfff6816b6ace65f4
MD5 4164d7ce4822d16d6e84c5abffa04812
BLAKE2b-256 5ee1acb543fda59f1be3ad72eb65b237061b6ac506230cdb6fee40adca91562f

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp33-cp33m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp33-cp33m-win_amd64.whl
  • Upload date:
  • Size: 182.7 kB
  • Tags: CPython 3.3m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 0d04e7843195e7988e1c7208fb87cf85e119f351ceffd71c8e4249c09a624c9b
MD5 ca425f39470262e232f9702a5b19e6ff
BLAKE2b-256 1ac6962e7a3309d042f8dcdfd9a0cfdda5c2be7e1528e18a714dad820dafae3e

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp33-cp33m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp33-cp33m-win32.whl
  • Upload date:
  • Size: 166.1 kB
  • Tags: CPython 3.3m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 dbc4137ffc7449e17f17453ad4b292090824a544eb4413290913f51e98b3171c
MD5 b4a9cd13e19ba07087cd2e5f1aafa371
BLAKE2b-256 d8ea48014220996beff396cab95ec8f0edb3d2415791bc987aa7896ca122e65a

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 184.3 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 7e78ec60f03faf000768ced87ccf9ecbe3dfe31386d9278b0d2312e3b60c3f04
MD5 38d0eb91c7c294e6cf335f0f455a6d69
BLAKE2b-256 362bed0d91e460775c9a2d8660771f58420931cce6a577537ba875c5c7841885

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.7-cp27-cp27m-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.7-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 167.9 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.1

File hashes

Hashes for sxtwl-1.0.7-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 1cf20b13f3bb76f2a1145f1dca482cf0c85aa6b021b8ab86ae0337ce64820552
MD5 cb54c2512777b77d80bc43f4c4e15f3c
BLAKE2b-256 b63683b1d1a1c26c9f9ef1d621e74788918379ef16437eec6e26cdce6b9538a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page