从列表循环中将变量放入引号中?

2024-05-14 03:56:39 发布

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

我试图使用以下代码循环浏览一系列硬币:

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

最有效的方法是什么?我必须把我的名单分开吗?谢谢您!你知道吗


Tags: 代码inforparse硬币urllibitemquote