Python3 List reverse()方法

Python 3 教程 · 2019-02-06 13:57:25

描述

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

语法

reverse()方法语法:

list.reverse()

参数

  • NA。

返回值

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

实例

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

#!/usr/bin/python3

list1 = ['Google', 'Codercto', 'Taobao', 'Baidu']
list1.reverse()
print ("列表反转后: ", list1)

以上实例输出结果如下:

列表反转后:  ['Baidu', 'Taobao', 'Codercto', 'Google']

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

查看所有标签

The Hard Thing About Hard Things

The Hard Thing About Hard Things

Ben Horowitz / HarperBusiness / 2014-3-4 / USD 29.99

Ben Horowitz, cofounder of Andreessen Horowitz and one of Silicon Valley's most respected and experienced entrepreneurs, offers essential advice on building and running a startup—practical wisdom for ......一起来看看 《The Hard Thing About Hard Things》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具