How to assign each element of a list to a separate variable?

前端 未结 7 1740
花落未央
花落未央 2020-12-01 14:12

if I have a list, say:

ll = [\'xx\',\'yy\',\'zz\']

and I want to assign each element of this list to a separate variable:

v         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 14:44

    If the number of Items doesn't change you can convert the list to a string and split it to variables.

    wedges = ["Panther", "Ali", 0, 360]
    a,b,c,d = str(wedges).split()
    print a,b,c,d
    

提交回复
热议问题