Created
May 21, 2020 07:08
-
-
Save Eserthesay/6a7e3ddb67714b8db8193992e494d62b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = "https://community-open-weather-map.p.rapidapi.com/find" | |
querystring = {"type":"link%2C accurate","units":"metric","q":"istanbul"} | |
headers = { | |
'x-rapidapi-host': "community-open-weather-map.p.rapidapi.com", | |
'x-rapidapi-key': "{API KEY'inizi buraya girmelisiniz.}" | |
} | |
response = requests.request("GET", url, headers=headers, params=querystring) # istek gönderiyoruz. | |
print(response.text) | |
type(response) | |
resp=response.json() | |
print(resp) | |
type(resp) # response tipi ile farkını görmeniz için. | |
resp.keys() | |
resp2=resp['list'][0] | |
print(resp2) | |
for k,v in resp2.items(): | |
print("keys:{} \t values:{}".format(k,v)) # son dictionary'i key ve value'lara ayırdık. | |
resp2['main']['temp_min'] | |
sehir=input('Lütfen şehir adı girin: ') | |
if sehir.lower() =='istanbul': | |
x=(lambda : 'Bugün yağmursuz bir hava var.' if resp2['rain']==None else "Bu sabah yağmur var {}'da".format(sehir)) | |
print(x()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment