亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是否可以在 Python3 中的特定函數之外附加代碼行?

是否可以在 Python3 中的特定函數之外附加代碼行?

瀟瀟雨雨 2021-10-26 18:57:14
我正在嘗試獲取加密貨幣交易所的訂單簿如何支持特定對(例如 ETH/BTC)。因為我的函數需要每分鐘運行一次,所以每次檢查都非常耗時。我正在使用 ccxt 來獲取交易所的訂單簿。用這行代碼,我檢查每一次交換。import ccxtbinance   = ccxt.binance()livecoin  = ccxt.livecoin()kucoin    = ccxt.kucoin()hitbtc    = ccxt.hitbtc()kraken    = ccxt.kraken()crex24    = ccxt.crex24()okex      = ccxt.okex()headerList = ["time","type","pair"]try:    orderbookBinance = binance.fetch_order_book(self.pair,5)    headerList.append("binance")    headerList.append("binanceAmount")except:    print("Pair isn't available in binance")try:    orderbookLivecoin = livecoin.fetch_order_book(self.pair,5)    headerList.append("livecoin")    headerList.append("livecoinAmount")except:    print("Pair isn't available in livecoin")try:    orderbookKucoin = kucoin.fetch_order_book(self.pair,5)    headerList.append("kucoin")    headerList.append("kucoinAmount")except:    print("Pair isn't available in kucoin")try:    orderbookHitbtc = hitbtc.fetch_order_book(self.pair,5)    headerList.append("hitbtc")    headerList.append("hitbtcAmount")except:    print("Pair isn't available in hitbtc")try:    orderbookKraken = kraken.fetch_order_book(self.pair,5)    headerList.append("kraken")    headerList.append("krakenAmount")except:    print("Pair isn't available in kraken")try:    orderbookCrex24 = crex24.fetch_order_book(self.pair,5)    headerList.append("crex24")    headerList.append("crex24Amount")except:    print("Pair isn't available in crex24")try:    orderbookOkex = okex.fetch_order_book(self.pair,5)    headerList.append("okex")    headerList.append("okexAmount")except:    print("Pair isn't available in okex")現在我需要添加所有 try-blocks 的第一行,如果它們可以輸出的話。這在python中可能嗎?
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 212 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號