Python set突变:AttributeError:'set'对象没有属性'k'

问题描述 投票:0回答:1

我必须实际解决图像中的问题。但是我不知道为什么它会产生属性错误。有人可以解释一下这是什么意思,以及如何在我的代码中避免它。[problem]

A= int(input())
set1=set(map(int,input().split()))
N=int(input())
for i in range(N):
    k,*a=input().split()
    set2=set(map(int,input().split()))
    set1.k(set2)

print(sum(set1))
python-3.x set
1个回答
0
投票

set1.k(set2)。您想在这里做什么?如果要更新或添加使用:set1.add(set2)set1.update(set2)

© www.soinside.com 2019 - 2024. All rights reserved.