Python List reverse()方法

栏目: 编程语言 · Python · 编程教程 · python 教程 · 发布时间: 9年前

内容简介:reverse() 函数用于反向列表中元素。

描述

reverse() 函数用于反向列表中元素。

语法

reverse()方法语法:

list.reverse()

参数

  • NA。

返回值

该方法没有返回值,但是会对列表的元素进行反向排序。

实例

以下实例展示了 reverse()函数的使用方法:

#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 'xyz'];

aList.reverse();
print "List : ", aList;

以上实例输出结果如下:

List :  ['xyz', 'abc', 'zara', 'xyz', 123]

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具