timeIn.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Jarvis 作者: sukeesh 项目源码 文件源码
def main(self, s):
    # Trims input s to be just the city/region name
    s = s.replace('time ', '').replace('in ', '')

    # Transforms a city name into coordinates using Google Maps API
    loc = getLocation(s)

    # Gets current date and time using TimeZoneDB API
    send_url = (
        "http://api.timezonedb.com/v2/get-time-zone?"
        "key=BFA6XBCZ8AL5&format=json"
        "&by=position&lat={:.6f}&lng={:.6f}".format(*loc)
    )
    r = requests.get(send_url)
    j = json.loads(r.text)
    time = j['formatted']
    self.dst = j['dst']
    # Prints current date and time as YYYY-MM-DD HH:MM:SS
    print(Fore.MAGENTA + "The current date and time in " +
          str(s).title() + " is: " + str(time) + Fore.RESET)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号