python
1import requests 2import json 3def get_weather(): 4 url = 'http://weather.livedoor.com/forecast/webservice/json/v1' 5 payload = {'city': '230010'} 6 data = requests.get(url, params = payload).json() 7 print("愛知県名古屋市の") 8 9 for weather in data['forecasts']: 10 if weather['temperature']['max'] is None: 11 Ondo = ("不明") 12 13 else: 14 Ondo = (weather['temperature']['max']['celsius'] + "度") 15 16 print(weather['dateLabel'] + "の天気は" + weather['telop'] + "、最高気温は" + (Ondo) + "です。") 17 18 19 20if __name__ == "__main__": 21 get_weather() 22
エラー内容
起動ををすると「No module named 'requests'」と出てきてしまいます。
試したこと
requestsモジュールのインストール ・pip install requests
エラー File "<stdin>", line 1
pip install requests
^
SyntaxError: invalid syntax
情報
・windows10 pro
・python3.6.5
・インストールサイト https://www.python.org/downloads/
・インストールはこのサイトの通りにやりました。https://www.python.jp/install/windows/install_py3.html
回答1件
あなたの回答
tips
プレビュー