How to remove extra ',' in tuple in django(python)

后端 未结 5 1280
长情又很酷
长情又很酷 2021-01-06 07:45

I have one problem in building a list of id using django. if i choose more than 1 id it ok but if i choose only one it will produce extra \',\' in list.

test         


        
5条回答
  •  失恋的感觉
    2021-01-06 07:57

    To write a tuple containing a single value you have to include a comma, even though there is only one value.

    You can index the tuple to get the desired output:

    print testa[0]
    >>>> 1234
    

提交回复
热议问题