خرید بک لینک

Vote count: 0

I am getting a response from API and sometimes it has an optional key called Selections. When it does not have the key I would like to have Selections: [] in MarketPrices like below:

{'Timestamp': datetime.datetime(2016, 4, 3, 21, 14, 19, 726967, tzinfo=<suds.sax.date.FixedOffsetTimezone object at 0x7f805fffed50>), 'MarketPrices': [{'Selections': [],'_RetuCode': 16, '_Id': 7308747L}, {'_RetuCode': 16, '_Id': 1L}], 'RetuStatus': {'_Code': 0, '_CallId': 7bc619bd-2805-4205-85ff-6fa5b48ea899, '_Description': Success}}

I am trying to set default keys with dict.setdefault('Selections', []) but I get:

{'Selections': [],'Timestamp': datetime.datetime(2016, 4, 3, 21, 14, 19, 726967, tzinfo=<suds.sax.date.FixedOffsetTimezone object at 0x7f805fffed50>), 'MarketPrices': [{'Selections': [],'_RetuCode': 16, '_Id': 7308747L}, {'Selections': [],'_RetuCode': 16, '_Id': 1L}], 'RetuStatus': {'Selections': [],'_Code': 0, '_CallId': 7bc619bd-2805-4205-85ff-6fa5b48ea899, '_Description': Success}}   

How can I specify that the default value should be in MarketPrices?

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 17 فروردين 1395 ساعت: 15:20

صفحه بندی