フロート私は、複数の都市の地理座標のペアを持つテキストファイルOpenweathermapのAPIがエラー
import requests
import smtplib
import urllib
def get_location():
geocode={}
latlon=open('latlononly.txt', 'r')
for line in latlon:
(lat, lon)=line.split(',')
geocode[lat]=lon.strip()
return geocode
def get_weather(geocode):
api='xxxx'
for x, y in geocode.items():
url='http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&units=imperial&appid='+api+''.format(x,y)
weather_r=requests.get(url)
weather_j=weather_r.json()
print(weather_j)
geocode=get_location()
get_location()
get_weather(geocode)
print(geocode)
は、エラーが右の「{」タラということである持っています'{0}は浮動小数点ではありません'} '
.format()を浮動小数点に変換するにはどうすればよいですか?または、私はその前にフロートにジオコード辞書を変更しましたか?私はtxtファイルを読み込みたいので、Openweathermap APIを複数の場所に使用するのではなく、その場で変更することができます。