在Python中处理列表之reverse()方法的使用教程,pythonreverse
在Python中处理列表之reverse()方法的使用教程,pythonreverse
reverse()方法代替逆转列表对象。
语法
以下是reverse()方法的语法:
list.reverse()
参数
- NA
返回值
此方法不返回任何值,但反转列表中的给定对象。
例子
下面的例子显示了reverse()方法的使用。
#!/usr/bin/python aList = [136, 'xyz', 'zara', 'abc', 'xyz','hema']; aList.reverse(); print "List : ", aList;
当我们运行上面的程序,它会产生以下结果:
List : ['hema','xyz', 'abc', 'zara', 'xyz', 126]
相关内容
- Python去除字符串两端空格的方法,python字符串
- 在Python中使用sort()方法进行排序的简单教程,pythonsor
- Python合并字符串的3种方法,python合并3种
- Python字符串逐字符或逐词反转方法,python字符串
- Linux下使用python自动修改本机网关代码分享,linuxpytho
- 初步讲解Python中的元组概念,讲解python概念
- Python批量按比例缩小图片脚本分享,
- Linux下用Python脚本监控目录变化代码分享,linuxpython
- Python检测字符串中是否包含某字符集合中的字符,pyt
- Python中字典的基本知识初步介绍,python字典知识
评论关闭