Python add item to the tuple

后端 未结 7 2092
暗喜
暗喜 2020-12-22 16:11

I have some object.ID-s which I try to store in the user session as tuple. When I add first one it works but tuple looks like (u\'2\',) but when I try to add ne

7条回答
  •  暖寄归人
    2020-12-22 17:03

    You need to make the second element a 1-tuple, eg:

    a = ('2',)
    b = 'z'
    new = a + (b,)
    

提交回复
热议问题