"""
列表常用操作
- 列表连接
- 获取长度
- 遍历列表
- 列表切片
- 列表排序
- 列表反转
- 查找元素
Version: 1.0.0
Author: Catherine
Data: 2019-03-11
"""
def main():
fruits = ["grape", "apple", "strawberry", "waxberry"]
print(fruits)
fruits += ['pitaya', 'pear', 'mango']
print(fruits)
for fruit in fruits:
print(fruit.title(), end=' ')
print()
fruits2 = fruits[1:4]
print(fruits2)
fruits3 = fruits[:]
print(fruits3)
fruit4 = fruits[-3:-1]
print(fruit4)
fruits5 = fruits[::-1]
print(fruits5)
if __name__ == "__main__":
main()
列表2-python3
最新推荐文章于 2021-06-29 21:37:48 发布