E
E
EGORIKEBOLIK2020-12-30 14:17:48
Python
EGORIKEBOLIK, 2020-12-30 14:17:48

How to fix Python AttributeError: 'dict' object has no attribute 'vk_api' error?

I recently started learning Python, I'm trying to make a parser for id and the number of subscribers of VK groups
Code:

session = vk.Session(access_token = token)
vk_api = vk.API(session)
apivers = 5.92




def get_content():
    name = input("Введите название групп: ")
    
    
    groups = vk_api.groups.search(q = name, type = "group", v = apivers, city_id = 73, count = 1)
    list = []
    for group in groups:
        list.append({
            "id" : groups.vk_api.groups.getbyid('group_id'),
            "subs" : groups.vk_api.groups.getbyid(fields = "members_count")
            
        })
    
   
        
    print(list)
    print("--------------------------")
    print(len(list))
    return list
    
get_content()


Mistake:
Traceback (most recent call last):
  File "d:/Programming/PY/base.py", line 35, in <module>   
    get_content()
  File "d:/Programming/PY/base.py", line 23, in get_content
    "id" : groups.vk_api.groups.getbyid('group_id'),       
AttributeError: 'dict' object has no attribute 'vk_api'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-12-30
@EGORIKEBOLIK

groups - a dictionary, the dictionary does not have the vk_api attribute, what else to add

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question