Hello. I ’m rirocan, an active student.
I tried to display the time and today's weather w
time.py
# -*- coding: utf-8 -*-
import datetime#Basic date and time types
import multiprocessing#You can use the API to spawn a process.
import urllib2, sys#An extensible library for opening URLs.
import json
try: citycode = sys.argv[1]
except: citycode = '090010' #Default region
todaydetail = datetime.datetime.today()#Today's date
resp = urllib2.urlopen('http://weather.livedoor.com/forecast/webservice/json/v1?city=%s'%citycode).read()#today's weather
resp = json.loads(resp)
print '----------------------------------------------------------------------------------------'
print todaydetail#Today's date
print '----------------------------------------------------------------------------------------'
print resp['title']#today's weather
print resp['description']['text']
print '----------------------------------------------------------------------------------------'
Recommended Posts