快捷导航

怎么反向迭代一个序列?

怎么反向迭代一个序列

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

list的话,最快的方法使用reverse

tempList = [1,2,3,4]
tempList.reverse()
for x in tempList:
    print x
回复

使用道具 举报

templist = (1,2,3,4)
for i in range(len(templist)-1,-1,-1):
    print templist
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP