python中逆向输出列表
作者:互联网
001、
>>> test ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'] >>> test[-1] ## 逆向输出 'ff' >>> test[-2] 'ee'
002、
>>> test = ["aa", "bb", "cc", "dd", "ee", "ff"] >>> test ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'] >>> test[::1] ['aa', 'bb', 'cc', 'dd', 'ee', 'ff'] >>> test[::-1] ## 逆向输出列表 ['ff', 'ee', 'dd', 'cc', 'bb', 'aa'] >>> test[::-2] ## 逆向间隔输出 ['ff', 'dd', 'bb']
标签:aa,逆向,bb,python,dd,列表,ee,ff,test 来源: https://www.cnblogs.com/liujiaxin2018/p/16307464.html