我是 Python 新手,当我运行此代码时,出现此错误,请帮忙。 Error screenshot
import requests
from datatime import datatime
#https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR
URL = "https://min-api.cryptocompare.com/data/price?fsym={}&tsyms={}"
def get_price(coin,currency):
try:
respone = requests.get(URL.format(coin, currency)).json()
return respons
except:
return False
while True:
date_time = datetime.now()
date_time = data_time.strftime("%d/%m/%Y %H:%M:%S")
currentPrice = get_price(BTC,USD)
if currentPrice:
print(date_time, "BTC price: ", currentPrice, "$")
答案 0 :(得分:0)
您是否安装了“请求”?
试试这个。终端上的“pip install requests”