如何从日志调试中分离单个值

2024-05-29 10:26:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从输出中提取volume和last price的值到其他变量中,但我无法获取它们

结果如下

DEBUG:root:[{'timestamp': datetime.datetime(2018, 7, 24, 12, 23, 34), 'last_price': 90.35, 'oi_day_low': 37008, 'volume': 23308, 'sell_quantity': 6035, 'last_quantity': 2, 'change': -0.17126125628418445, 'oi': 43808, 'average_price': 90.3275363, 'ohlc': {'high': 90.43, 'close': 90.505, 'open': 90.3125, 'low': 90.28}

def on_ticks(ws, ticks):
# Callback to receive ticks.

logging.debug("{}".format(ticks))

Tags: debugdatetimerootchangepricetimestampquantitylow
1条回答
网友
1楼 · 发布于 2024-05-29 10:26:48
def on_ticks(ws, ticks):
    # Callback to receive ticks. 
    logging.debug("{}".format(ticks))
    var = ticks[0]['volume']
    var1 = ticks [0] ['last_price']  
    print(var)
    print(var2)

通过使用这个,它为我工作

相关问题 更多 >

    热门问题