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.9.tar.gz (159.0 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.9-cp38-cp38-win_amd64.whl (193.4 kB view details)

Uploaded CPython 3.8Windows x86-64

sxtwl-1.0.9-cp38-cp38-win32.whl (172.1 kB view details)

Uploaded CPython 3.8Windows x86

sxtwl-1.0.9-cp37-cp37m-win_amd64.whl (193.3 kB view details)

Uploaded CPython 3.7mWindows x86-64

sxtwl-1.0.9-cp37-cp37m-win32.whl (172.1 kB view details)

Uploaded CPython 3.7mWindows x86

sxtwl-1.0.9-cp36-cp36m-win_amd64.whl (193.3 kB view details)

Uploaded CPython 3.6mWindows x86-64

sxtwl-1.0.9-cp36-cp36m-win32.whl (172.1 kB view details)

Uploaded CPython 3.6mWindows x86

sxtwl-1.0.9-cp35-cp35m-win_amd64.whl (193.3 kB view details)

Uploaded CPython 3.5mWindows x86-64

sxtwl-1.0.9-cp35-cp35m-win32.whl (172.1 kB view details)

Uploaded CPython 3.5mWindows x86

sxtwl-1.0.9-cp34-cp34m-win_amd64.whl (194.3 kB view details)

Uploaded CPython 3.4mWindows x86-64

sxtwl-1.0.9-cp34-cp34m-win32.whl (170.8 kB view details)

Uploaded CPython 3.4mWindows x86

sxtwl-1.0.9-cp33-cp33m-win_amd64.whl (195.0 kB view details)

Uploaded CPython 3.3mWindows x86-64

sxtwl-1.0.9-cp33-cp33m-win32.whl (171.6 kB view details)

Uploaded CPython 3.3mWindows x86

sxtwl-1.0.9-cp27-cp27m-win_amd64.whl (196.9 kB view details)

Uploaded CPython 2.7mWindows x86-64

sxtwl-1.0.9-cp27-cp27m-win32.whl (173.1 kB view details)

Uploaded CPython 2.7mWindows x86

File details

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

File metadata

  • Download URL: sxtwl-1.0.9.tar.gz
  • Upload date:
  • Size: 159.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9.tar.gz
Algorithm Hash digest
SHA256 f99c04bdbf201e40fd379d0803abc64d74367aac22ac9628aa84e7970a204659
MD5 7231cea76976d4d626f9a1dd9a9b6da9
BLAKE2b-256 310dc3cf54c4a90d2bd356354c2dff6edc55b262b669917fa5a3d7a003b173f0

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sxtwl-1.0.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 193.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 8760c6b86c24193e77241a2e7021ce9e19c81559309f5991cd8f924cf6326b76
MD5 13742f7f3bd994de0480bf19b1208211
BLAKE2b-256 f20960db9420a8e1e29ca90988b19f3f56b21577c8d12c94eabd041a85ac3587

See more details on using hashes here.

File details

Details for the file sxtwl-1.0.9-cp38-cp38-win32.whl.

File metadata

  • Download URL: sxtwl-1.0.9-cp38-cp38-win32.whl
  • Upload date:
  • Size: 172.1 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 7553ab9b675319254c7d7ab89d6bc6b126853dd7d8226c7978365c75ec2758d9
MD5 72d9439242792b47653331d36c809906
BLAKE2b-256 13aeec669a5cef3317f47760b090679e7b6b0091da9adcaedc35fd8ae03e4b4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 193.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1876a475e569ba2f23d3101b8f720fdf636f4a307e42521f0f3423b03c333b43
MD5 4a4404106824e1eb4b6e4d98685022f2
BLAKE2b-256 a2aac77fad6cce97c19f771db6f39df2f6bfd9c863dcf5afc71c799b698ed70a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 172.1 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 3b64c0dbab08c3332bbf5eb9de8647b9b802a250deb8c18f2ed0221069690bef
MD5 c3096badbf18ae75a12fbe28dfdbaf9b
BLAKE2b-256 e1298c913416aea64230da4e5b9444c7b863a83396457f383f648d20198121a3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 193.3 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c16ea44cbf0053156770713c7276d2b574f575574cc3ac6b7f7954f914576b85
MD5 77b7366a44e71ed98699f5e425e3ed59
BLAKE2b-256 7583e4297cc73173a68b28c44a2a0fdd51f8e3b81afb5e66787cabf13b77ae01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 172.1 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 6e89f8fae58f47df2231cb5bfffec238f92c5ec103b9c08e8ea85c197e486e75
MD5 c678a47454c66a88033ad539c5f98734
BLAKE2b-256 b66a332f3c662883d5013e34cbf9a59d551323b6dd4fe357ce686206f536b6d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 193.3 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 4dc6bb96b5406435883daf442123a3b088c71651ca04e3beb95d0128ac147358
MD5 54af517b1d93c1b163d2cc1748fb0938
BLAKE2b-256 4adc0116c16175a8207bd0c956666b095886334c434d2152c8e3fbe06a08ceed

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 172.1 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 f2ce0249a3baaca7d4de05b00c63c24adddcd38a2fb2571f3efbf6e3a49c3ab6
MD5 6fd9e529fcea0e0595dc28631aa524dd
BLAKE2b-256 e8625663632346e6b525b7b49d94b6e2f5ebcb32f8d7b27bd1e2a4de36e49bd6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp34-cp34m-win_amd64.whl
  • Upload date:
  • Size: 194.3 kB
  • Tags: CPython 3.4m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 6b53b108fbf95227c53f8bd016d40369eab832099cd16b2a196d7868557263b8
MD5 e8d0dd786d79ff3612697103896016d3
BLAKE2b-256 718573adf3de51691cfac0b6d28934bfeeab38d2ab08589fb983a945c39df59d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp34-cp34m-win32.whl
  • Upload date:
  • Size: 170.8 kB
  • Tags: CPython 3.4m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 a74b2b556a493b763a6e0706ab84207947ee5d4c12d6720439a8ffe9eeb329f4
MD5 770fec9a4a8422912d56dd51776f50c7
BLAKE2b-256 f69255e5942c4abef5e877815a13f818e09dcb409303e45d3617674899c8e05b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp33-cp33m-win_amd64.whl
  • Upload date:
  • Size: 195.0 kB
  • Tags: CPython 3.3m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 f23593d60d12f925d5e935b1d6747fcaca84dec720b5023117bbdb1a83e138ff
MD5 62aa749cae156a6a047747df12600e66
BLAKE2b-256 f3de93268028378ef8ab60ee66314a5b43beab9f2e425b31a27019f925a88c61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp33-cp33m-win32.whl
  • Upload date:
  • Size: 171.6 kB
  • Tags: CPython 3.3m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 a2f503f306bb65a7cac7aa0da7f2c66f9371c91d6e52ac54c835a2ddfb722b26
MD5 c95285f2f83212e62321e36985f6ce9a
BLAKE2b-256 6355e353e2e6816d8b9e2db1e6e5a0ba4c2ead4e8ab240bbd64cebdb2185901c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 196.9 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 7a5119e9f922c10e7e35058b6280df0159e3652977e58b29dc393947d2df6be7
MD5 1d0d974f514f6329fe9aaa7670627e47
BLAKE2b-256 0166f549c668fb58ed3e9890214b60f52b369c0c4577ed733400326c57c4d40a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sxtwl-1.0.9-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 173.1 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for sxtwl-1.0.9-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 e91fcd66038c094ad7b5bcc64908dc60a5076745b61c1e566544eecd522fe853
MD5 1172bd9585922b4eb74b2926568b79f2
BLAKE2b-256 51c9a930f914be902da9c4f821b979f14509073c8f66d34fdf77e20e60ceac38

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