方法一:
names = ['Alice', 'Bob', 'David', 'Ellenal']
for i in range(len(names)-1,-1,-1):
print(names[i])
方法二:
names = ['Alice', 'Bob', 'David', 'Ellenal']
for i in reversed(names):
print(i)
举例
for i in range(3,-1,-1):
print(i)
输出:3,2,1,0
开始3,步长-1,结束-1,(-1不打印,打印前面一位,即0)