python中用方法reverse()可以倒转列表的顺序
例如
wang = ‘tianxiao’
people = [wang,23,‘shui’,‘xiang’]
print(people)
people.reverse()
print(people)
输出结果
[‘tianxiao’, 23, ‘shui’, ‘xiang’]
[‘xiang’, ‘shui’, 23, ‘tianxiao’]
使用方法len()可以快速获取列表的长度
len(people)
4
python中用方法reverse()可以倒转列表的顺序
例如
wang = ‘tianxiao’
people = [wang,23,‘shui’,‘xiang’]
print(people)
people.reverse()
print(people)
输出结果
[‘tianxiao’, 23, ‘shui’, ‘xiang’]
[‘xiang’, ‘shui’, 23, ‘tianxiao’]
使用方法len()可以快速获取列表的长度
len(people)
4