gpt4 book ai didi

Python:需要超过 1 个值才能解包

转载 作者:行者123 更新时间:2023-11-28 19:41:08 24 4
gpt4 key购买 nike

出现此错误我做错了什么?

    replacements = {}
replacements["**"] = ("<strong>", "</strong>")
replacements["__"] = ("<em>", "</em>")
replacements["--"] = ("<blink>", "</blink>")
replacements["=="] = ("<marquee>", "</marquee>")
replacements["@@"] = ("<code>", "</code>")

for delimiter, (open_tag, close_tag) in replacements: # error here
message = self.replaceFormatting(delimiter, message, open_tag, close_tag);

错误:

Traceback (most recent call last):
File "", line 1, in for doot, (a, b) in replacements: ValueError: need more than 1 value to unpack

所有值元组都有两个值。对吧?

最佳答案

应该是:

for delimiter, (open_tag, close_tag) in replacements.iteritems(): # or .items() in py3k

关于Python:需要超过 1 个值才能解包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2609136/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com