码迷,mamicode.com
首页 > 编程语言 > 详细

python逆序

时间:2020-07-26 00:56:00      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:splay   rev   eve   isp   one   python   逆序   切片   pytho   

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

python逆序

标签:splay   rev   eve   isp   one   python   逆序   切片   pytho   

原文地址:https://www.cnblogs.com/Marigolci/p/13377708.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!