Python List reverse()方法

Python 教程 · 2019-02-02 22:58:38

描述

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]

点击查看所有 Python 教程 文章: https://codercto.com/courses/l/8.html

查看所有标签

The Intersectional Internet

The Intersectional Internet

Safiya Umoja Noble、Brendesha M. Tynes / Peter Lang Publishing / 2016

From race, sex, class, and culture, the multidisciplinary field of Internet studies needs theoretical and methodological approaches that allow us to question the organization of social relations that ......一起来看看 《The Intersectional Internet》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具