反转列表
我的源代码:
#!/usr/bin/python
# encoding=utf-8
# -*- coding: UTF-8 -*-#按照相反的顺序输出列表的各元素l = ["test1","test2",3,("test3",2),5,9]
m = l[::-1]
print("NO.1:",l)
print("NO.2:",m)
l.reverse()
print("NO.3:",l)
结果:
————————(我是分割线)————————
参考:
1. RUNOOB.COM:https://www.runoob.com/python/python-exercise-example32.html
备注:
初次编辑时间:2019年10月5日16:08:39
环境:Windows 7 / Python 3.7.2