L
L
loadi2017-08-04 21:53:14
Python
loadi, 2017-08-04 21:53:14

Python vk api banal request?

import vk
session = vk.Session()
vk_api = vk.API(session)
loadi =str (vk_api.users.get(user_id=1))
print (loadi)

This outputs to the console: [{'uid': 1, 'first_name': 'Pavel', 'last_name': 'Durov'}]
I need to get the first_name from here. How can this be done quickly and easily?
Spoiler
Sorry for dumb questions :D

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Astrohas, 2017-08-04
@loadi

import vk
session = vk.Session()
vk_api = vk.API(session)
loadi =vk_api.users.get(user_id=1)
print(loadi[0]['first_name'])

K
Kirill Zhilyaev, 2017-08-04
@kirill_782

Decode JSON and extract

D
Denis Michurin, 2017-08-04
@denistu10

print (loadi[first_name])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question