本文共 833 字,大约阅读时间需要 2 分钟。
python获取比特币数据
Using the API, you can easily fetch the current price using a very small Python script.
使用 API,您可以使用非常小的Python脚本轻松获取当前的价格。
import import requestsrequestsurl url = = 'http://data.mtgox.com/api/2/BTCUSD/money/ticker''http://data.mtgox.com/api/2/BTCUSD/money/ticker'r r = = requestsrequests .. getget (( urlurl , , headersheaders == { { 'Accept''Accept' : : 'application/json''application/json' })})print print rr .. jsonjson ()[()[ 'data''data' ][][ 'avg''avg' ][][ 'display_short''display_short' ]]
If you want to support for multiple currencies and more information, here’s an extended version:
如果您想支持多种货币和更多信息,请使用以下扩展版本:
Usage:
用法:
$ python bitcoin.py---BTCUSDLow: $ 305.00Average: $ 362.75High: $ 395.00Last: $ 342.00---BTCEURLow: € 221.85Average: € 272.07High: € 298.00Last: € 253.01---
翻译自:
python获取比特币数据
转载地址:http://tnqwd.baihongyu.com/