1 bicycles = ['trek', 'cannondale', 'redline', 'specialized'] 2 print(bicycles) 3 bicycles.reverse() #倒置原列表,永久性修改列表元素,但可恢复 4 print(bicycles) 5 bicycles.reverse() #倒置列表,恢复为原列表 6 print(bicycles)
1 运行结果应该是: 2 ['trek', 'cannondale', 'redline', 'specialized'] 3 ['specialized', 'redline', 'cannondale', 'trek'] 4 ['trek', 'cannondale', 'redline', 'specialized']