python列表输出倒序


     
     
     
     
  1. lists = [ 1, 3, 4, 5, 6, 7, 9, 2]
  2. # 切片
  3. print lists[:: -1]
  4. # 函数reverse 对数组进行操作
  5. lists.reverse()
  6. print lists
  7. # 函数reversed 返回一个迭代对象,需要list化
  8. print list(reversed(lists))

 

你可能感兴趣的:(python学习)