我正在尝试使用此代码循环显示硬币列表:
coin = ["BTC", "NEO", "ETH"]
for item in coin:
try:
term = urllib.parse.quote("'" + coin + "-BTC'")
depth = client.get_order_book(term, limit=50)
except (KucoinAPIException, KucoinRequestException, KucoinResolutionException) as e:
print(e)
pass
我收到错误:
TypeError: must be str, not list
实现这一目标的最有效方法是什么?我必须拆分我的清单吗?谢谢!
答案 0 :(得分:1)
使用for
循环来实现这一点可能更容易(和高效/ Pythonic):
coin = ["BTC", "NEO", "ETH"]
for i in coin:
term = urllib.parse.quote("'" + i + "-BTC'")
depth = client.get_order_book(term, limit=50)