Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thsU= {
- 'success': 0,
- 'return': {
- '0000000000': {
- 'pair': '', 'type': '', 'amount': 0.0, 'rate': 0.0, 'timestamp_created': 0000000, 'status': 0
- }
- }
- }
- vals = list(thsU['return'].values())
- print(vals)
- print(vals[0]['rate'])
- In [5]: dictionary = {
- ...: 'success': 0,
- ...: 'return': {
- ...: '0000000000': {
- ...: 'pair': '', 'type': '', 'amount': 0.0, 'rate': 0.0, 'timestamp_created': 0000000, 'status
- ...: ': 0
- ...: }
- ...: }
- ...: }
- In [6]: dictionary['return'][list(dictionary['return'].keys())[0]]['rate']
- Out[6]: 0.0
- assert len(some_dict['return']) == 1
- [nested_dict] = some_dict['return'].values()
- print(nested_dict['rate']) # -> 0.0
- nested_dict = next(iter(some_dict['return'].values()))
- print(nested_dict['rate']) # -> 0.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement