Python 从字典中提取天气数据-spotfire

Python 从字典中提取天气数据-spotfire,python,ironpython,spotfire,Python,Ironpython,Spotfire,我想在spotfire中以html数据表的形式获取天气数据。Spotfire确实提供了Ironpython支持,但没有灵活性来添加我们自己的模块。所以这里是速记。在这种情况下,使用iframe和src作为api没有帮助 我的剧本: import clr clr.AddReference('System.Data') clr.AddReference('System.Web.Extensions') import System from System import DateTime from Sy

我想在spotfire中以html数据表的形式获取天气数据。Spotfire确实提供了Ironpython支持,但没有灵活性来添加我们自己的模块。所以这里是速记。在这种情况下,使用iframe和src作为api没有帮助

我的剧本:

import clr
clr.AddReference('System.Data')
clr.AddReference('System.Web.Extensions')
import System
from System import DateTime
from System.Data import DataSet, DataTable
from System.IO import StreamReader, StreamWriter, MemoryStream, SeekOrigin
from System.Net import HttpWebRequest
from System.Web.Script.Serialization import JavaScriptSerializer
from Spotfire.Dxp.Data import DataType, DataTableSaveSettings
from Spotfire.Dxp.Data.Import import TextFileDataSource, TextDataReaderSettings


#uri = "http://api.openweathermap.org/data/2.5/weather?q=London&appid=ec0313a918fa729d4372555ada5fb1f8"
uri = "http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743&units=metric&appid=ec0313a918fa729d4372555ada5fb1f8"
webRequest = HttpWebRequest.Create(uri)
response = webRequest.GetResponse()
streamReader = StreamReader(response.GetResponseStream())
jsonData = streamReader.ReadToEnd()
js = JavaScriptSerializer()
dataDict = js.Deserialize(jsonData, object)

print dataDict

# Close the connection
response.Close()
我需要从字典dataDict中提取多个城市的一些公共值,如:Name、Id、Description、temperature

我在这里碰到一块石头

如果您能帮助我/指导我如何从这本复杂的字典中获取这些值,那就太好了


示例dataDict:
Dictionary[str,object]({'cnt':3,'list':数组[object]({'coord':Dictionary[str,object]({'lon':,'lat':}),'sys':Dictionary[str,object]({'type':1,'id':7323,'message':,'country':'RU,'sunrise':1484372967,'sunset':1484400490}),'weather':数组[object]('Dictionary')[str,object]({'id':802,'main':'Clouds','description':'scattered Clouds','icon':'03d'),'main':Dictionary[str,object]({'temp':,'pressure':1009,'weather':80,'temp(min':-2,'temp(max':-1}),'visibility','10000,'wind':Dictionary[str,object]({'speed','speed':6,'deg':160,'gust':12}),'({'all':40}),'dt':1484398800,'id':524901,'name':'Moscow'}),字典[str,object]({'coord':字典[str,object]({'lon':,'lat':}),'sys':字典[str,object]({'type':1,'id':7358,'message','country':'UA','sunrise':1484373141,'sunset':1484403724}),'weather':数组[object]('Dictionary[str,object]({'id':804,'main':'Clouds','description':'Clouds','icon':'04d'})),'main':Dictionary[str,object]({'temp':3,'pressure':998,'湿度]:86,'temp_min':3,'temp_max':3}),'visibility':10000,'wind':Dictionary[str,object]({'speed':4,'deg':170,'var_beg':100,'var_end':210}),'Clouds':[str,object]({'all':90}),'dt':1484398800,'id':703448,'name':'Kiev'),字典[str,object]({'coord':字典[str,object]({'lon':,'lat':}),'sys':字典[str,object]({'type':1,'id':5091,'message':,'country':'GB','sunrise':1484380764,'sunset':1484410813}),'weather':数组[object]((字典)[str,object]({'id':501,'main':'Rain','description':'medium Rain','icon':'10d'),'main':Dictionary[str,object]({'temp':,'pressure':1020,'湿度]:80,'temp(min':2,'temp(max':6}),'visibility':10000,'wind':Dictionary[str,object]({'speed':,'deg':290}),'clouds':Dictionary[str,object]({'all':20,'dt':1484400000,'id':2643743,'name':'London'})),

“我需要[做xx]…我在这里碰到了一堵石头[墙]。”有点不清楚。你描述了你到目前为止所做的事情(这很好!),但你真正的问题是什么?从JSON中提取某些数据(我猜)对象?您的示例dataDict不是有效的JSON或Python数据结构,例如
dict
list
。请回答您的问题,并以这两种形式之一提供它。是的,红色,我希望显示一些数据,但我将其归结为:打印dataDict[“list”]#我正在考虑将其放入len的循环中(dataDict[“list”])-1获取动态值。除非您有更好的建议/解决方案:)