2014-11-22 32 views
1

我有一個字典從網頁上作爲.JSON()對象,我使用下面的代碼格式被返回:向此代碼的元素添加格式?

responser = responser.json() 

teamStatDicts = responser[u'teamTableStats'] 

for statDict in teamStatDicts: 

    mylookup = ("{tournamentName},{tournamentId},{regionCode},{tournamentRegionId},{teamName},{teamId}," 
    "{minsPlayed},{ranking},{rating},{apps},".decode('cp1252').format(**statDict)) 

的這將使毫安輸出樣本:

Premier League,2,gb-eng,252,Arsenal,13,75,1,6.22145454545,5,1.0,4.5,5.5, 

在這個例子中我想要對項目{rating}應用格式,以便它只有兩位小數。是否有可能修改上面的代碼來做到這一點?

感謝

+0

可以請你在'teamStatDicts'更新'teamStatDicts [0]'或任何項目更好的理解,感謝 – 2014-11-22 17:22:10

+0

@ Md.Mohsin您好,感謝回答。我不確定你在問我什麼。 – gdogg371 2014-11-22 17:24:29

回答