python - 使用 HTTP 请求进行过滤
问题描述
我目前正在使用 XT.com API(加密货币兑换)。我想在这个交易所获得加密货币的最新价格。到目前为止,以下是我的代码:
ticker = api.get_ticker(dict(market='btc_usdt'))
#XTPrice = ticker['price']
print(ticker)
运行这段代码给了我这个:
Please wait a moment...retry now... times is 1
(True, {'high': 50494.6, 'low': 47993.99, 'rate': 0.0267, 'price': 50174.41, 'moneyVol': 40012402.49752388, 'coinVol': 809.706147, 'ask': 50173.88, 'bid': 50172.19, 'askVol': 0.147934, 'bidVol': 0.052413, 'depthTime': 1629726830489}, <Response [200]>)
我想只保留“价格”部分。我试图添加代码:
XTPrice = ticker['price']
print(XTPrice)
但这会导致错误。
任何人都可以为我提供任何帮助吗?
解决方案
ticker[1]['price']
Epsi95 提供的代码
推荐阅读
- webpack - 在 vue 的 simple-webpack 模板中,build.js 来自哪里?
- java - 从桌面快捷方式运行 bash 脚本时保持终端打开
- jquery - 检查一个类附近是否在jQuery中添加了另一个类
- python - _tkinter.TclError: 字符 U+1f40d 超出 Tcl 允许的范围 (U+0000-U+FFFF)
- xml - XML 转换适用于一个文件,但不适用于另一个
- visual-studio - Visual Studio中VSCode的CTRL + D(“将选择添加到下一个位置匹配”)的等效快捷方式是什么?
- java - Apache freemarker 不会使用 gradle 导入
- python - 熊猫在没有分配的情况下更改 DataFrame 中的行
- r - RMarkdown - 更改内联代码颜色
- java - 如何在java中读取文本文件?