Ошибка с функцией, принимающей 1 позиционный аргумент, но 2 были даны - PullRequest
0 голосов
/ 28 сентября 2019

Это часть одного из скриптов, которые я запускаю для Discord Python Bot.Среди прочего, бот способен отображать текущую погоду.Он принимает данные и возвращает эти данные.Но когда я проверил его и дал ему местоположение, он вернул ошибку.

@client.event
async def on_message(message):
 UserInput=message.content.split(" ")

 if len(UserInput)==3:
   if UserInput[0]=="!lb" and UserInput[1]=="cw":
     obs = owm.weather_at_place(str(UserInput[2]))                   
     #CityID_Current_Weather = owm.weather_at_id(int(UserInput[2]))                           
     #Lat_Lon_Current_Weather = owm.weather_at_coords(float(UserInput[2]),float(UserInput[3]))  <-- len == 4 !!

     if isinstance(UserInput[2], str):
       try:
         current_weather = obs.get_weather(str(UserInput[2]))
         cloud_coverage = current_weather.get_clouds()
         rain_volume = current_weather.get_rain()
         snow_volume = current_weather.get_snow()
         wind_degree_speed = current_weather.get_wind()
         humidity = current_weather.get_humidity()
         pressure = current_weather.get_pressure() 
         temperature = current_weather.get_temperature(unit = "celsius")
         STATUS = current_weather.get_detailed_status()
         weather_icon = current_weather.get_weather_icon_url()

         #test command
         await message.channel.send(str(cloud_coverage)) #this raised the error


       except: 
         await message.channel.send("""Oops! Looks like something broke :cry: Check the command syntax or message Lemon to fix it.
Don't remember the syntax or need some quick help? Use `!lb help`.""")
         await message.channel.send("||"+"**"+str(traceback.format_exc())+"**"+"||")         

#end current weather

Ошибка:

File "C:\Users\user\Desktop\name\name\name\name\LemonBot\LemonBot_Weather\LemonBot_Weather.py", 
line 43, in on_message
    current_weather = obs.get_weather(str(UserInput[2]))
TypeError: get_weather() takes 1 positional argument but 2 were given

Это сообщение об ошибке, которое возникает при отправке команды cloud_coverage данные были выполнены.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...