There is an api that gives the answer in json format:

response = requests.get(URL) response.json() {u'u0446\u0430\u044c': {u'id': 15, u'text': ttttt}} 

this happens if there are Russian letters. Are there ways to "use" keys? In place of u0446\u0430\u044c , there can be anything. This key appears in the request, but in the normal form.

  • 3
    What is the question? Take yes use, normal key. - andreymal
  • Yes, only there can be anything. How to get the value of "text"? - gasasder
  • All the available keys can be obtained using the .keys() method from the dictionary, and then do what you want with them - andreymal

2 answers 2

For example:

 >>> dct {'u0446аь': {'id': 15, 'text': 'ttttt'}} >>> dct[list(dct.keys())[0]]['text'] 'ttttt' 

    To get the value corresponding to the "text" key, from the first nested dictionary in the given dictionary outer_dict :

     inner_dict = next(outer_dict.itervalues()) text = inner_dict['text'] 

    or for small dictionaries:

     inner_dict = outer_dict.values()[0] 

    In Python 3:

     inner_dict = next(iter(outer_dict.values()))