T
T
timur kup2020-09-03 19:20:28
Python
timur kup, 2020-09-03 19:20:28

SyntaxError: invalid syntax in vk_api, help?

I wrote an autostatus for the VK page, took a piece of code from another person that determines how many likes on ava and displays it in status.
Error: 5f51177895858341112223.png
Part of code:

import vk_api
import time
import json
from urllib import request
import requests

token = "my_token"

while True:
    vk = vk_api.VkApi(token)
    on = vk.method("friends.getOnline")
    counted = len(on)
    vk.method("status.set", {"text": " Друзей онлайн: " + str(counted)})

def startStatus():
    try:
        getLikes = requests.get(f"https://api.vk.com/method/photos.get?album_id=profile&rev=1&extended=1&count=1&v=5.95&access_token={token}").json()
        getLikes = getLikes["response"]["items"][0]["likes"]["count"]
    except IndexError:
        print("У профиля отсутсвует аватар или лайки.")
        getLikes = 0


    statusSave = (" Лайков на аве: " + str(getLikes).format(getLikes))
    statusOut = requests.get(f"https://api.vk.com/method/status.set?text={statusSave}&v=5.95&access_token={token}").json()
    if statusOut.get("error", None):
        print(f"Не удалось обновить статус сервер вернул неверный код ответа: {statusOut}")
    else:
        print(f"Статус был обновлен")

while True:
    startStatus()
    time.sleep(30)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dr. Bacon, 2020-09-03
@timur_ffsdfdsf

So go version of python that doesn't know how to f-string yet

S
soremix, 2020-09-03
@SoreMix

And did you take the version of python from another person, or did you use your own, below 3.6?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question