Answer the question
In order to leave comments, you need to log in
Gives an error 'str' object is not callable, how to fix it?
Since I have scripts for hosting, when I try to do something with the time, the hosting time is set there (it is in America), I need Moscow time. This is part of the script for the Vkontakte network.
from urllib import request
import requests
import pytz
import datetime
import urllib
import json
import time
import vk
token = "Token"
timeKD = 60
session = vk.Session(access_token = token)
api = vk.API(session, v = "5.95")
def startStatus():
moscowtime = str(datetime.datetime.now(pytz.timezone('Europe/Moscow'))) #Ошибки
fmt = "%Y-%m-%d %H:%M:%S"
statusOut = api.status.set(text = "Сведения: " + moscowtime(fmt))
while True:
startStatus()
print('обновлено')
time.sleep(timeKD)
Answer the question
In order to leave comments, you need to log in
I'm no expert, but try this:
moscowtime = datetime.datetime.now(pytz.timezone('Europe/Moscow'))
fmt = "%d-%m-%Y %H:%M:%S"
statusOut = api.status.set(text = "Сведения: " + str(moscowtime(fmt)))
moscowtime = str(datetime.datetime.now(pytz.timezone('Europe/Moscow')))
fmt = "%d-%m-%Y %H:%M:%S"
statusOut = api.status.set( text = "Time: " + moscowtime)
This works, but you need to show the time in the format "%d-%m-%Y %H:%M:%S"
moscowtime = datetime.datetime.now(pytz.timezone('Europe/Moscow'))
fmt = "%Y-%m-%d %H:%M:%S"
statusOut = api.status.set(text = "Сведения: " + moscowtime.strftime(fmt))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question