#!/usr/bin/python # -*- coding: utf-8 -*- import json, os, math os.chdir('/home/pi/tmp') with open('forecast.json') as fc_file: df = json.load(fc_file) # print df datum = df['list'][0]['dt_txt'] datum2 = datum[8:-9] + "." + datum[5:-12] + "." + datum[0:-15] datump = "" zeit = datum[11:-3] print "
Datum | Zeit | " print "Temp ° C | "
print "Feuchte % | "
print "Wolken | " print " | Wind km/std | "
print "Richtung ° | "
print "Regen | |
---|---|---|---|---|---|---|---|---|---|
" + datum2 + " | " print "" + zeit + " | " temp = df['list'][n]['main']['temp'] - 273.15 nachk,grad = math.modf(temp) nachk = nachk * 10 if temp < 0: print "" + "-%2d,%1d" % (abs(grad),abs(nachk)) + " | " else: print "" + "%2d,%1d" % (grad,nachk) + " | " print "" + str(df['list'][n]['main']['humidity']) + " | " print "" + df['list'][n]['weather'][0]['description'] + " | " icon = df['list'][n]['weather'][0]['icon'] print "" + "%3d,%1d" % (wind,nachk) + " | " wrichtg = df['list'][n]['wind']['deg'] nachk,richtg = math.modf(wrichtg) print "" + "%3d" % (richtg) + " | " try: nied = df['list'][n]['rain']['3h'] except KeyError: nied = 0 print "" + str(nied) + " | " print "