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.6.tar.gz (158.6 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.6-cp37-cp37m-win_amd64.whl (180.6 kB view details)

Uploaded CPython 3.7mWindows x86-64

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

Uploaded CPython 3.7mWindows x86

sxtwl-1.0.6-cp36-cp36m-win_amd64.whl (180.6 kB view details)

Uploaded CPython 3.6mWindows x86-64

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

Uploaded CPython 3.6mWindows x86

sxtwl-1.0.6-cp35-cp35m-win_amd64.whl (180.6 kB view details)

Uploaded CPython 3.5mWindows x86-64

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

Uploaded CPython 3.5mWindows x86

sxtwl-1.0.6-cp34-cp34m-win_amd64.whl (181.9 kB view details)

Uploaded CPython 3.4mWindows x86-64

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

Uploaded CPython 3.4mWindows x86

sxtwl-1.0.6-cp33-cp33m-win_amd64.whl (182.6 kB view details)

Uploaded CPython 3.3mWindows x86-64

sxtwl-1.0.6-cp33-cp33m-win32.whl (166.0 kB view details)

Uploaded CPython 3.3mWindows x86

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

Uploaded CPython 2.7mWindows x86-64

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

Uploaded CPython 2.7mWindows x86

File details

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

File metadata

  • Download URL: sxtwl-1.0.6.tar.gz
  • Upload date:
  • Size: 158.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6.tar.gz
Algorithm Hash digest
SHA256 bd05c6020e3389765fdbd3da972283de83398880e4b724480bf3c361b14c9911
MD5 da3dd114650cae14ef9c1b9bb249eb0e
BLAKE2b-256 a580d7bf9c5fc3213e0c83513ecfb0c27e814eeb4e18aea9d8bba6caafc03f39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 180.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f28317c5a9d1fceba38caf9abe3d6806f813d0c21e6ad8fddeca663eab63c954
MD5 5fd2063cb41643bdfb40e34fb6401b1d
BLAKE2b-256 e51cacb78d37e1d1862e5f896b6848ae331913e410212b57f3487649d2ba6364

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 9b738279efff962d69fc29cc988f6a8b84ac109b769589731eadf429665081a5
MD5 ea214ef8ff59d905bbc8d84f2a22a37c
BLAKE2b-256 abbef7585b57a5557bf83711a946679228530cbbde323582530f0ea84310339e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 180.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8a6c046dd32e6897e47eaf880af664c718b170f64e6819c69b2e206ea1db2fb1
MD5 91aedeee672484602a26dbfc7a812766
BLAKE2b-256 7fe679bf7196c8c735ae3ee5fafde761afdb75ab38c734a4399caea01ee19a0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 ca8b32ee09a12955ea8bb8fab869cc6042cdbf30b0caf1dc66f8315e8dbfa1e0
MD5 a1f7cfffdb411f8bd949b8d246a53787
BLAKE2b-256 3979210c5bf8db5b1afde5bd04118af8f970f2329fce974cbd5d49fdef9bddc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 180.6 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 ec389dcb69f17a51f2f6ab0ed9290a285fb4115fa8d4ff6892b3f8766851a529
MD5 907fdf1b8193bc3576da65592fb73808
BLAKE2b-256 57bf4e1c8f9d2feb733271477d11ee31c56c40dfe96d96150778e7ec0d91f5b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 7690031a122aa295c0843600c36f5b4cea7365bf70c74b383d189160ea876c30
MD5 e41bf3dffdf1194bff8406d7af028daa
BLAKE2b-256 e81dfa1da344f1e17d86ee50e636affa508ec71bd7726694960991dfd40457a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp34-cp34m-win_amd64.whl
  • Upload date:
  • Size: 181.9 kB
  • Tags: CPython 3.4m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 baf7455c6e9c178304f096c8262cb805310fafa65567d6d8142942ed0cb6d57b
MD5 0dab7280b054d89f5590ae1821e2ebef
BLAKE2b-256 5276b40fdfbd1c2279de6629edd2a6bb0aeefa630f2cb13de60e1382e1fa389b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 02dc8ac180e9d0011adb876b620ed4fa6a68ddb510d2a1a03977d65232367269
MD5 7f3e846ae84f960b5f70e8889223df22
BLAKE2b-256 3fb6b3a3411ca1126a1ca7156001535b3bf10c671820752ce7afc206413b4b39

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp33-cp33m-win_amd64.whl
  • Upload date:
  • Size: 182.6 kB
  • Tags: CPython 3.3m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 e488c590fa90a9b8886a0f8943ef78359778cbe673483ac3a468d323823d76dd
MD5 d2e9af1243e0f47407f3288862cf98ae
BLAKE2b-256 9bc139135022d8f83fe3e18a137959306c769211f972ec310b28a711081dae75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-cp33-cp33m-win32.whl
  • Upload date:
  • Size: 166.0 kB
  • Tags: CPython 3.3m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 576253a3d85df2151696fc3cf34e9941c01e66ac44d8a49bd0b0de20766ad75a
MD5 f14118b26253ff8275494c19c964ed06
BLAKE2b-256 32ebe5c09d276090a5f8344fa0fdde381cde272edc438e07c6b816b9eb333a1f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 93fe40ff78c08bbe58e3092f518dd872355bd536809e142265bef7d23f3ae03c
MD5 b5ad9942dbcb4deac598124d4a11cdfb
BLAKE2b-256 cab5d37ba8412063c65a99a9e1e58a32c90ec36008d4ee0c488f0d8fb4c6915f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.6-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for sxtwl-1.0.6-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 668a749b1d9abc0951ee9cd770fb54fa55b37681b3de7ee7355d953277a9716c
MD5 bbbcc6d698fe090eee1f314d2b077b5d
BLAKE2b-256 a93b5a45d808bdc01e4c8fb1173f23ca52bbab6e8dd5b2d7d96980c136d2ce26

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