过滤/选择变量输出=简单的简单问题,但我不知道如何搜索正确的解决方案

问题描述 投票:0回答:1

我敢肯定这很简单,但是我找不到合适的词来解释我对Google的意思,因此我的搜索空了。

我有一个要打印到控制台的变量。都好。

我想过滤/选择变量输出,因此我可以在新变量中引用它。我只是不知道该命令的正确语法。

这是变量:

all_orderbooks = client.get_orderbook_ticker()

print(all_orderbooks)

这将输出大量数据,代码段在这里:

[{'symbol':'ETHBTC','bidPrice':'0.02475200','bidQty':'0.00800000','askPrice':'0.02475700','askQty':'112.26500000'},{'symbol': 'LTCBTC','bidPrice':'0.00469900','bidQty':'0.05000000','askPrice':'0.00470100','askQty':'70 .00000000'},{'symbol':'BNBBTC','bidPrice': '0.00177020','bidQty':'73 .94000000','askPrice':'0.00177060','askQty':'10 .34000000'},{'symbol':'NEOBTC','bidPrice':'0.00112600','bidQty': '8.71000000','askPrice':'0.00112700','askQty':'981.97000000'},{'symbol':'QTUMETH','bidPrice':'0.00734200','bidQty':'296.42000000','askPrice': '0.00736400','askQty':'296.33000000'},{'symbol':'EOSETH','bidPrice':'0.01107500','bidQty':'300.00000000','askPrice':'0.01108900','askQty': '300.00000000'},{'symbol':'SNTETH','bidPrice':'0.00010647','bidQty':'10188.00000000','askPrice':'0.00010703','askQty':'1917.00000000'},{'symbol ':'BNTETH','bidPrice':'0.00345900','bidQty':'0.82000000','askPrice':'0.00346000','askQty':'535.00000000 '},{'symbol':'BCCBTC','bidPrice':'0.00000000','bidQty':'0.00000000','askPrice':'0.00000000','askQty':'0.00000000'},{'symbol': 'GASBTC','bidPrice':'0.00017920','bidQty':'11 .55000000','askPrice':'0.00017980','askQty':'115.18000000'},{'symbol':'BNBETH','bidPrice': '0.07145400','bidQty':'23 .87000000','askPrice':'0.07154800','askQty':'93 .35000000'},{'symbol':'BTCUSDT','bidPrice':'9280.37000000','bidQty': '0.02339500','askPrice':'9280.38000000','askQty':'0.49950000'},{'symbol':'ETHUSDT','bidPrice':'229.74000000','bidQty':'1.76697000','askPrice': '229.75000000','askQty':'144.09608000'},{'symbol':'HSRBTC','bidPrice':'0.00000000','bidQty':'0.00000000','askPrice':'0.00000000','askQty': '0.00000000'},{'symbol':'OAXETH','bidPrice':'0.00000000','bidQty':'0.00000000','askPrice':'0.00000000','askQty':'0.00000000'},{'symbol ':'DNTETH','bidPrice':'0.00000000','bidQty':'0.00000000','askPrice':'0.00000000','askQty':'0.00000000'},{ 'symbol':'MCOETH','bidPrice':'0.02187700','bidQty':'44 .94000000','askPrice':'0.02205000','askQty':'0.48000000'},{'symbol':'ICNETH', 'bidPrice':'0.00000000','bidQty':'0.00000000','askPrice':'0.00000000','askQty':'0.00000000'},{'symbol':'MCOBTC','bidPrice':'0.00054290', 'bidQty':'7.00000000','askPrice':'0.00054390','askQty':'0.30000000'},{'symbol':'WTCBTC','bidPrice':'0.00003810','bidQty':'922.47000000', 'askPrice':'0.00003830','askQty':'8641.66000000'},{'symbol':'WTCETH','bidPrice':'0.00153900','bidQty':'3.35000000','askPrice':'0.00154800', 'askQty':'43 .06000000'},{'symbol':'LRCBTC','bidPrice':'0.00000992','bidQty':'785.00000000','askPrice':'0.00000997','askQty':'25373.00000000'} ,{'symbol':'LRCETH','bidPrice':'0.00040116','bidQty':'98 .00000000','askPrice':'0.00040320','askQty':'67 .00000000'},{'symbol':'QTUMBTC ','bidPrice':'0.00018200','bidQty':'1.23000000','askPrice':'0.00018220','askQty':'915.96000000'},{'symbo l':'YOYOBTC','bidPrice':'0.00000110','bidQty':'82154.00000000','askPrice':'0.00000111','askQty':'365041.00000000'},{'symbol':'OMGBTC',' bidPrice':'0.00016630','bidQty':'938.17000000','askPrice':'0.00016670','askQty':'900.83000000'},{'symbol':'OMGETH','bidPrice':'0.00671100',' bidQty”:“ 330.64000000”,“ askPrice”:“ 0.00673800”,“ askQty”:

我希望能够过滤/选择文本中的特定主题,即“符号:”,然后仅显示符号。

我认为我必须创建一个新变量并指定我想要的目标,即print(all_orderbooks.symbol)或print(all_orderbooks)_symbol,但是到目前为止,努力一直没有结果。

任何帮助将不胜感激。

这是我的决议] >>

all_orderbooks = client.get_orderbook_ticker()
for order in all_orderbooks:
    ordersymbol = (order['symbol'])
    print(ordersymbol)

非常感谢

我敢肯定这很简单,但是我找不到合适的词来解释我对Google的意思,因此我的搜索空了。我有一个要打印到控制台的变量。都好。我是...

python function variables output binance
1个回答
0
投票

好吧,我知道了,它可以工作,但是如果有更好的方法,那么我绝对乐于学习:)

© www.soinside.com 2019 - 2024. All rights reserved.