The error message 'AttributeError: 'list' object has no attribute 'update'' indicates that you're attempting to use the update() method on a list object, which is not supported in Python. Lists do not have the update() method, which is a method used for sets.

To fix this issue, you need to ensure that the tags_merge[id] value is a set object before calling the update() method. Here's a corrected version of your code:

for parameter in parameters[0]['input_3'][0]:
    id = parameter['container']
    tags = parameter['tags']
    if id not in tags_merge:
        if tags:
            tags_merge[id] = set(tags)
        else:
            tags_merge[id] = set('-')
    else:
        if tags:
            tags_merge[id].update(tags)
        else:
            tags_merge[id].update('-')

In this updated code, the update() method is only called when tags is not empty. Otherwise, it updates the set with a single '-' character. This ensures that tags_merge[id] is always a set object before calling the update() method, preventing the AttributeError.


原文地址: https://www.cveoy.top/t/topic/qqwO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录