Problemas con app clima python. No funciona. Copiada de Internet
Publicado por María (22 intervenciones) el 15/07/2020 16:49:48
Tras copiar el código de Internet, no me funciona. A el en youtube el autor si le funciona. Creo qu mi fallo está en la dirección al servidor de donde se acceden a los datos metereologicos pero no doy con el error porque yo lo veo todo igual que lo que tiene el chico de youtube
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 15 10:30:12 2020
@author: maria
"""
#
#Programa basado en:
# https://www.youtube.com/watch?v=UDA2wTas9QQ
#api.openweathermap.org/data/2.5/weather?q={city name}&appid={your api key}
#Para la llamada al servidor del clima hay que instalar previamente la libreria
# requests. install pip3 requests. Esto permite solocitar la información al servidor.
from tkinter import *
import requests
def clima(ciudad):
API_key="13d9b394398922a7f0e4831259f3ef66"
URL="https://api.openweathermap.org/data/2.5/weather"
parametros={"APPID": API_key,"q":ciudad,"units":"metric"}
response=requests.get(URL,params=parametros)
print(response.json())
ventana = Tk()
ventana.geometry("350x350")
texto_ciudad= Entry(ventana, font=("Courier", 20,"normal"), justify="center")
texto_ciudad.pack(padx=30,pady=30)
obtener_clima=Button(ventana, text="Obtener clima")
obtener_clima.pack()
mostrar_clima=Label(text="weather",font=("Courier",20,"normal"))
mostrar_clima.pack(padx=30,pady=30)
ventana.mainloop()
Valora esta pregunta


0