Skip to main content

安装方法

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)
  • 如果使用此项目,请告之一下作者
  • 如果您使用了此项目的代码,为了表示对寿星天文历原作者的尊重,请您项目适当的位置表达对许剑伟先生感谢
  • 如果你觉得本库不错,欢迎打赏作者

微信用户打赏入口:

微信支付

支付宝用户打赏入口:

支付宝

Release files for sxtwl 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sxtwl 1.0.8
File Size Uploaded
sxtwl-1.0.8.tar.gz 160.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sxtwl 1.0.8
File
sxtwl-1.0.8-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
sxtwl-1.0.8-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
sxtwl-1.0.8-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
sxtwl-1.0.8-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
sxtwl-1.0.8-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
sxtwl-1.0.8-cp34-cp34m-win_amd64.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp34-cp34m-win32.whl CPython 3.4 CPython 3.4 pymalloc Windows x86-32 Details
sxtwl-1.0.8-cp33-cp33m-win_amd64.whl CPython 3.3 CPython 3.3 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp33-cp33m-win32.whl CPython 3.3 CPython 3.3 pymalloc Windows x86-32 Details
sxtwl-1.0.8-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
sxtwl-1.0.8-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details

Total release size: 2.7 MB

Release files / sxtwl-1.0.8.tar.gz

Download URL sxtwl-1.0.8.tar.gz
Size 160.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8c200e549a2d92fd8bd77707eae79872bf82fdbd59c06e7b9abe6ae42f4c3043
BLAKE2b-256 checksum
How to use checksums
7235bbf463ad2a5e8eef7e4c2ca75f41b4c80f8e79f4d06cb44a7eee99edf36b
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp38-cp38-win_amd64.whl

Download URL sxtwl-1.0.8-cp38-cp38-win_amd64.whl
Size 187.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
3c0aa84e9fcecf117e454087f3f757e0d09dcc556b290bc9851a24e0a8aec8fc
BLAKE2b-256 checksum
How to use checksums
3b400d788af57c532912f6798b9ecd03a1e9ec8cafd3250cad7ff19e495a1d8b
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp38-cp38-win32.whl

Download URL sxtwl-1.0.8-cp38-cp38-win32.whl
Size 172.4 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
76b624c42aaa492093b475d0b141322faaabbc3ac9d1217e2ca68901acfda55e
BLAKE2b-256 checksum
How to use checksums
55dea3ce0323ad8ba857f03e33156e85a3c35923f8186a9ef9d8070edf690578
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp37-cp37m-win_amd64.whl

Download URL sxtwl-1.0.8-cp37-cp37m-win_amd64.whl
Size 187.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
23e31c2235205e3a6b66bdd4c1e99a01e7c02c7623c8f56393eb15a4497f0b4f
BLAKE2b-256 checksum
How to use checksums
948711e690f5d971156097fb3c959ec25df01bb800cbd69015b9f3f995de0629
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp37-cp37m-win32.whl

Download URL sxtwl-1.0.8-cp37-cp37m-win32.whl
Size 172.3 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
043d89f166406f7f59b93112f7ef7cfebc345751326b0f19ea1dc7bda4dda36d
BLAKE2b-256 checksum
How to use checksums
61ba4c7d929471ba8c6379515a7771e78b239b68c4da5e26cfd5c45debe87228
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp36-cp36m-win_amd64.whl

Download URL sxtwl-1.0.8-cp36-cp36m-win_amd64.whl
Size 187.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
53ef092ccbc49699afeedab52879105bc8f9fd5521d13f5e059221588061b474
BLAKE2b-256 checksum
How to use checksums
17c8aacce53806d0adb029cdda4f5502b80f53c2f4bdf30d61e5927870e5c6a9
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp36-cp36m-win32.whl

Download URL sxtwl-1.0.8-cp36-cp36m-win32.whl
Size 172.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
3492fd4163fe931f537af01d31102c5b93cb75d2ce37f803c355237999781e20
BLAKE2b-256 checksum
How to use checksums
aa44faf22b3749d2fd5f7a9a04345e54d8aa8301e48516dc23568cee953d09d6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp35-cp35m-win_amd64.whl

Download URL sxtwl-1.0.8-cp35-cp35m-win_amd64.whl
Size 187.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
eb15a351e89a984345b4625647c8c94c31a8547a6e6107c39da5bd2412fd3401
BLAKE2b-256 checksum
How to use checksums
9392ec84bf94bdeeeae3e80c818e7d8c86e8b6a10cb753df1090780dc29f17aa
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp35-cp35m-win32.whl

Download URL sxtwl-1.0.8-cp35-cp35m-win32.whl
Size 172.3 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
697c4428e4d64fe3f571d9bec87dd552ec70e76245b35c8d3091289a18dfbf9c
BLAKE2b-256 checksum
How to use checksums
12a8efde8dc0791db5994f08dee4f525298854d7aabc4c869d210b6d95b7e70c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp34-cp34m-win_amd64.whl

Download URL sxtwl-1.0.8-cp34-cp34m-win_amd64.whl
Size 188.9 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
cce72082e8c370d5f5a1765de50ace328c42bb49c469be64de5e321fbf1059a9
BLAKE2b-256 checksum
How to use checksums
e68417780006a77f44f4cf942e8a2ac53d12dd93820a113a7df1e37be12a530f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp34-cp34m-win32.whl

Download URL sxtwl-1.0.8-cp34-cp34m-win32.whl
Size 171.5 kB
Tags CPython 3.4 CPython 3.4 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
54d11256f3ccca9098966c020e51842a5845eae15cd03c4e3557be82f4d0e1d6
BLAKE2b-256 checksum
How to use checksums
901ab6ed927b4de97127245574e0a2c9e2eb35e8bfed567fe0842dd8e4228588
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp33-cp33m-win_amd64.whl

Download URL sxtwl-1.0.8-cp33-cp33m-win_amd64.whl
Size 189.7 kB
Tags CPython 3.3 CPython 3.3 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
90412236028746d94ffa8bcf31d12612e803832ae5ba0f8865cf61febb83ee2a
BLAKE2b-256 checksum
How to use checksums
100da8b64e28b864a958b6cc467cdd30acc6b3be84faf35f723a1251f8b4b712
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp33-cp33m-win32.whl

Download URL sxtwl-1.0.8-cp33-cp33m-win32.whl
Size 172.2 kB
Tags CPython 3.3 CPython 3.3 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
f39d077d3aa643686ce5ff0409971dae636558cd233d296e2001b84bc991eda2
BLAKE2b-256 checksum
How to use checksums
d6af855cbbb59b1ecf09367eb396361bdb865d125f477e168c06845fe71c01c6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp27-cp27m-win_amd64.whl

Download URL sxtwl-1.0.8-cp27-cp27m-win_amd64.whl
Size 191.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d45866cb3893cbe31987ea5af71a05352ed9cb6ccf8e41433121ec7416fed835
BLAKE2b-256 checksum
How to use checksums
767a70a69441c174505bc6e0a9f4d64acaf0fa59f5d7a9a1d70fdd1098a82db8
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sxtwl-1.0.8-cp27-cp27m-win32.whl

Download URL sxtwl-1.0.8-cp27-cp27m-win32.whl
Size 173.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
24d0707a4120b4d84d9b99b3a84eaa181c78a2753aa843261c5185580e8b1ecf
BLAKE2b-256 checksum
How to use checksums
5f4303480ed5b5073ea20524bfc0168e0bb6ee6c2490d470a15f4f9b8ea092c6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

2.0.5

1 release file

2.0.4

59 release files

2.0.3

59 release files

2.0.2

40 release files

This release

1.0.8 This release

15 release files

1.0.7

13 release files

1.0.6

13 release files

1.0.5

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page