Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. thsU= {
  2. 'success': 0,
  3. 'return': {
  4. '0000000000': {
  5. 'pair': '', 'type': '', 'amount': 0.0, 'rate': 0.0, 'timestamp_created': 0000000, 'status': 0
  6. }
  7. }
  8. }
  9.  
  10. vals = list(thsU['return'].values())
  11. print(vals)
  12. print(vals[0]['rate'])
  13.  
  14. In [5]: dictionary = {
  15. ...: 'success': 0,
  16. ...: 'return': {
  17. ...: '0000000000': {
  18. ...: 'pair': '', 'type': '', 'amount': 0.0, 'rate': 0.0, 'timestamp_created': 0000000, 'status
  19. ...: ': 0
  20. ...: }
  21. ...: }
  22. ...: }
  23.  
  24. In [6]: dictionary['return'][list(dictionary['return'].keys())[0]]['rate']
  25. Out[6]: 0.0
  26.  
  27. assert len(some_dict['return']) == 1
  28.  
  29. [nested_dict] = some_dict['return'].values()
  30. print(nested_dict['rate']) # -> 0.0
  31.  
  32. nested_dict = next(iter(some_dict['return'].values()))
  33. print(nested_dict['rate']) # -> 0.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement