ll= [1,2,3,4,5]
print ll[::-1]
ll.reverse()
for l in reversed(ll):
print l
倒序读取文件:
with open(filepath,‘rb‘) as fo: lines = fo.readlines() #lines是一个list for line in reversed(lines): #倒序读取行 print line
时间: 2024-10-12 06:04:30
ll= [1,2,3,4,5]
print ll[::-1]
ll.reverse()
for l in reversed(ll):
print l
倒序读取文件:
with open(filepath,‘rb‘) as fo: lines = fo.readlines() #lines是一个list for line in reversed(lines): #倒序读取行 print line