简单日落日出时间计算python库

suntime的Python项目详细描述


太阳时间

简单的日落和日出时间计算python库

安装

使用pip:

pip3 install suntime

或下载并键入:

python3 setup.py install

用法

您可以使用库获取UTC和当地时间日出和日落时间,输入:

importdatetimefromsuntimeimportSun,SunTimeExceptionlatitude=51.21longitude=21.01sun=Sun(latitude,longitude)# Get today's sunrise and sunset in UTCtoday_sr=sun.get_sunrise_time()today_ss=sun.get_sunset_time()print('Today at Warsaw the sun raised at {} and get down at {} UTC'.format(today_sr.strftime('%H:%M'),today_ss.strftime('%H:%M')))# On a special date in your machine's local time zoneabd=datetime.date(2014,10,3)abd_sr=sun.get_local_sunrise_time(abd)abd_ss=sun.get_local_sunset_time(abd)print('On {} the sun at Warsaw raised at {} and get down at {}.'.format(abd,abd_sr.strftime('%H:%M'),abd_ss.strftime('%H:%M')))# Error handling (no sunset or sunrise on given location)latitude=87.55longitude=0.1sun=Sun(latitude,longitude)try:abd_sr=sun.get_local_sunrise_time(abd)abd_ss=sun.get_local_sunset_time(abd)print('On {} at somewhere in the north the sun raised at {} and get down at {}.'.format(abd,abd_sr.strftime('%H:%M'),abd_ss.strftime('%H:%M')))exceptSunTimeExceptionase:print("Error: {0}.".format(e))

许可证

版权所有©2019 Satagro Sp.Z O.O.和撰稿人:

此文件是python(suntime)suntime库的一部分。

SunTime是自由软件:您可以根据自由软件基金会(free software Foundation)发布的GNU Lesser通用公共许可证(GNU Lesser General Public License)的条款(许可证的第3版或任何更高版本)重新分发和/或修改它

Pun> SunTimes的分布是希望它有用,但没有任何保证;甚至没有对适销性或适合特定用途的默示保证。有关更多详细信息,请参阅GNU Lesser通用公共许可证。

您应该已经收到GNU Lesser通用公共许可证的副本以及CAMS工具如果没有,请参阅http://www.gnu.org/licenses/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
使用jaxb2annotateplugin和XJC工具的java自定义注释   java组织。xeustechnologies。jcl无法加载WstxInputFactory类   java JUnit在格式化字符串上比较失败   java Bukkit配置部分getKeys   如何关闭Java流?   java Struts2正则表达式配置   链式事务注释的java奇怪行为   java在两个JButton之间使用变量   java签署APK时内容会发生什么变化?   java LWJGL:Slick:3D世界中的绘图字体   如何分解Java数组?   在Java MySql中处理多个过滤器   java如何在Firebase数据库中跳过初始OnChildaded事件触发   java如何在PreviewView中使用CameraX?   在子类#中重写父类后访问父类原始方法的java已解决   java找不到类型的属性   游戏框架游戏!框架+Java