B
B
Bug2019-12-09 06:08:32
Python
Bug, 2019-12-09 06:08:32

How to extract title from VK API data returned by getConversationsById method?

The code:

def get_chat(peer_ids):
  get_chat=vk.messages.getConversationsById(peer_ids=peer_id)
  print(get_chat)

Here vk_api I get a block of code:
{'count': 1, 'items': [{'peer': {'id': 20000000**, 'type': 'chat', 'local_id': **}, 'last_message_id': 0, 'in_read': 0, 'out_read': 0, 'can_write': {'allowed': True}, 'chat_settings': {'owner_id': 322925658, 'title': 'Spamchik | Чат-менеджер', 'state': 'in', 'acl': {'can_change_info': True, 'can_change_invite_link': False, 'can_change_pin': True, 'can_invite': True, 'can_promote_users': False, 'can_see_invite_link': False, 'can_moderate': True, 'can_copy_chat': True}, 'members_count': 5, 'photo': {'photo_50': 'https://sun9-71.userapi.com/c855620/v855620352/18b455/EPPMmGq..', 'photo_100': 'https://sun9-2.userapi.com/c855620/v855620352/18b454/rmvCC2u-..', 'photo_200': 'https://sun9-34.userapi.com/c855620/v855620352/18b453/PDXd2qJ..'}, 'admin_ids': [481247175, 529916063, 546143949, -183648733], 'active_ids': [322925658, 529916063, 481247175, 546143949]}}]}

I can't get the title from here .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shubin, 2019-12-09
@thema__python3

In your case:
But as I understand it, there may be several elements in items , or there may not be at all. This must be taken into account.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question