【问题标题】:How can I quickly retrieve Bitcoin's price from Bybit? (Python) [closed]如何快速从 Bybit 获取比特币价格? (Python)[关闭]
【发布时间】:2021-12-31 12:05:05
【问题描述】:

我在从 Bybit(连接到 Bybit API)检索比特币的当前价格时遇到问题。我想每隔 n 分之一秒更新一次比特币的当前价格。然而,从 Bybit 检索值似乎需要很长时间,因为它必须搜索一个大字典。有什么方法可以加快这个过程?

This is the code: (Bitcoin's price is being printed every second)

【问题讨论】:

标签: python bybit


【解决方案1】:

这段代码对我来说很好用:

import requests
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
data = response.json()
print(data["bpi"]["USD"]["rate"])

确保您已安装 requests。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-25
    • 2014-09-06
    • 2022-01-21
    相关资源
    最近更新 更多