N
N
nnicandeveloper2019-11-07 09:45:36
Python
nnicandeveloper, 2019-11-07 09:45:36

How to get the first and last name by id VK user Python?

gives an error:
line 3, in
session = vk.Session()
NameError: name 'vk' is not defined
how to do it right?

import vk_api

session = vk.Session()
api = vk.API(session, v = 5.103)
id = 1
response = api.users.get(user_ids = id)
first_name = response[0]['first_name']
second_name = response[0]['second_name']
print(first_name)
print(second_name)

PS solved, the problem was that vk and vk_api are different libraries

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
o5a, 2019-11-07
@o5a

Yes, this is code for vk library, not vk_api. And you will need authorization (access_token).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question