Python 获取实时比特币价格代码示例
以下是一个使用 Python 获取 BTC 实时报价的示例代码:
import requests
url = 'https://api.coindesk.com/v1/bpi/currentprice.json'
response = requests.get(url)
if response.status_code == 200:
data = response.json()
print('BTC Price: ' + data['bpi']['USD']['rate'])
else:
print('Failed to retrieve BTC price')
该代码使用 Coindesk 的 API 获取 BTC 的当前价格,并输出到控制台。您可以根据需要对其进行修改和扩展。
原文地址: https://www.cveoy.top/t/topic/nGQt 著作权归作者所有。请勿转载和采集!