python基礎--列表

  python列表listhtml

# 列表
list = ['a', 'b', 'c']
for str in list:
    print(str)
    
# append()方法來添加列表項
list2 = []
list2.append("hello")
list2.append(" python")
print(list2)

# del:根據索引來刪除列表的元素
del list2[1]
print(list2)

# len(列表):長度
print(len(list))

# 組合
print(list + list2)

# 重複
print(list * 2)

# 元素是否存在於列表中
if 'a' in list:
    print('list列表中包含有\'a\'')

 

  pop:刪除最後一個python

  remove(obj): 根據內容刪除一個app

  del list[索引]: 根據索引刪除spa

 

python列表的方法:https://www.runoob.com/python/python-lists.htmlcode

相關文章
相關標籤/搜索