用python实现:按相反的顺序输出列表的每一位值

1. 使用list[::-1]

 list1 = ["one","two","three","four"]
for i in list1[::-]:#list[::-]结果为列表的反向
print(i)

2. 使用list方法reverse()

 list1 = ["one","two","three","four"]
list1.reverse()
for i in list1:
print(i)

3. 使用python内置函数

 list1 = ["one","two","three","four"]
list2 =reversed(list1)
for i in list2:
print(i)

执行结果:

four
three
two
one
05-20 13:40