でアレイから複数の値を単一の値を比較すると、私のコードは次のようになります。のpython
import requests
import re
import mechanize
import urllib
import json
htmltext = urllib.urlopen("https://www.binance.com/api/v1/klines?symbol=BCDBTC&interval=4h")
data = json.load(htmltext)
current_price= data[len(data)-1][4]
last_prices= (data[len(data)-2][4],data[len(data)-3][4],data[len(data)-4][4],data[len(data)-5][4],data[len(data)-6][4])
last_volumes= (data[len(data)-2][5],data[len(data)-3][5],data[len(data)-4][5],data[len(data)-5][5],data[len(data)-6][5])
current_volume= data[len(data)-1][5]
print current_price
print last_prices
if current_price > last_prices:
print "the current price is greater than the last 5"
print current_volume
print last_volumes
if current_volume > last_volumes:
print "the current volume is higher than the last 5"
しかし、私の出力はこれです:ここでの問題は、現在のボリュームは確かではないです
0.00495600
(u'0.00492500', u'0.00366300', u'0.00332800', u'0.00333800', u'0.00308000')
the current price is greater than the last 5
938.01000000
(u'29687.32500000', u'14740.03800000', u'9366.77400000', u'10324.83200000', u'44953.53400000')
the current volume is higher than the last 5
最後の5よりも大きいが、それはまだ私がここに https://www.binance.com/tradeDetail.html?symbol=BCD_BTC
からデータをつかんだにかかわらずそれをプリントアウトしています
なぜ 'データ[-2]'の代わりに 'データ[LEN(データの)-2] 'はどこにでもありますか? – tonypdmtr