close
Python - Array (List 切片)
a[start:end:step] # 按照step步长直到end-1结束,并不是从start一个个遍历到end
a[start:end] # 从start开始到end-1结束
a[start:] # 从start开始直到末尾
a[:end] # 从头部开始直到end结束
a[:] # 复制整个列表
a[-1] # 列表最后一个元素
a[-2:] # 列表最后两个元素
a[:-2] # 除了最后两个元素剩下的部分
翻转字符串
str
=
'pythontab.com'
str
[::
-
1
]
# 'moc.batnohtyp'==============
參考
https://taizilongxu.gitbooks.io/stackoverflow-about-python/content/29/README.html
http://www.runoob.com/python/python-lists.html
http://www.pythontab.com/html/2018/pythonjichu_0413/1277.html
http://www.pythontab.com/html/2013/pythonjichu_0128/182.html
全站熱搜