2つのセット(tag_coordinates、tag_id)から返された値を関数から単一のセット(required_info)に更新するコードを記述しました。 required_infoの値を印刷しようとすると、値が2回印刷され、セット内の要素は順序付けされません。私はrequired_infoを印刷した後Setで関数から返された値を追加する方法は?
def GetLabels(taginfo): #this function gets the value taginfo, from an another code
tag_coordinates = set() #set to update tag_coordinates
tag_id = set() #set to update tag_id
required_info = set() #set to update required_info
r=60
for (tag,xy,orient,err,wl,sq) in taginfo:
xy2= (int(xy[0]+r*math.sin(math.radians(orient))),int(xy[1]-r*math.cos(math.radians(orient))))
tag_coordinates.add(xy) #corresponding tag_coordinates
tag_id.add(tag) #corresponding tag_id
required_info.update(tag_coordinates,tag_id)
print required_info
さて、私が設定tag_coordinatesから対応する値で、二度印刷されたセットを取得します、一緒に配置されていないTAG_ID。助言がありますか?
セットは数学で順序付けされる必要はないため、Pythonで記述されています。 – user1685095