data={}
for weightagesObj in weightagesAllObject:
item = {"weight":weightagesObj.weight, "rank":weightagesObj.rank}
data[weightagesObj.scrip] = item
nseJson=json.loads ( json.dumps(data) )
print ( nseJson["scrip name"] )
{
"RELIANCE": {
"weightage": 9.04,
"rank": 1
},
"TATAMOTORS": {
"weightage": 9.01,
"rank": 2
}
}
for weightagesObj in weightagesAllObject:
item = {"weight":weightagesObj.weight, "rank":weightagesObj.rank}
data[weightagesObj.scrip] = item
nseJson=json.loads ( json.dumps(data) )
print ( nseJson["scrip name"] )
{
"RELIANCE": {
"weightage": 9.04,
"rank": 1
},
"TATAMOTORS": {
"weightage": 9.01,
"rank": 2
}
}
No comments:
Post a Comment