day04_列表
列表:
增? :list.append("str")? 尾部添加? ? ?list.insert(index,str)? ? 通過索引值添加? ? list.extend( , )? 多個數值添加
刪? :list.pop() 默認最后一個彈出,可以添加索引值刪除? ? ?list.remove("str") 通過數值刪除? ?list.clear()? 清空列表? ?del list? 刪除整個列表
改:list[index] = str? ?通過索引值修改內容
查:索引,切片
公共:
len()? ?長度
list.count("str")? 出現次數?
list.sort()? 排序
list.sort(reverse = True)? ?從大到小
list.reverse()? ?反序
?
?
s = "sjsl;"
"-".join(s)? ?# join鏈接任意迭代對象
str.split() #分割字符串呈列表
?
li = [2,3,"sd","qd",[2,3,"c","z"],"sd"]for i in li:
if type(i) == list:
for j in i:
print(j)
continue
print(i)
轉載于:https://www.cnblogs.com/wzc27229/p/10934123.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
- 上一篇: FTP匿名登录或弱口令漏洞及服务加固
- 下一篇: Spring MVC国际化