Python学习笔记之疑问11:批量赋值
>>> a=b=c=1
>>> a
1
>>> b
1
>>> c
1
>>> 1
1
>>> d
可以使用a=b=c=1 这种方式连续赋值。或者先定义一个List,然后可以将这个list中的成员批量赋值给相应数量的变量
>>> range(7)
[0, 1, 2, 3, 4, 5, 6]
>>> (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY) = range(7)
>>> MONDAY
0 >>> TUESDAY 1 >>> SUNDAY 6
或者
>>> list1=[1,2,3]
>>> (a,b,c)=list1
>>> a
1
>>> b
2
>>> c
3
>>>