python 中交换两个列表元素的位置
>>> numbers = [5, 6, 7]
>>> i = 0
>>> numbers[i], numbers[i+1] = numbers[i+1], numbers[i]
>>> numbers
[6, 5, 7]
python是可以一次赋值两个变量的!谢谢!
>>> numbers = [5, 6, 7]
>>> i = 0
>>> numbers[i], numbers[i+1] = numbers[i+1], numbers[i]
>>> numbers
[6, 5, 7]
python是可以一次赋值两个变量的!谢谢!