append和extend 的區別
阿新 • • 發佈:2018-01-03
extend 區別 edi append true pre 打開列表 body int
l = ["zhy",666] l.extend(["edit","sdd"]) print(l) #[‘zhy‘, 666, ‘edit‘, ‘sdd‘] l.append(["bb","aa"]) print(l) #[‘zhy‘, 666, ‘edit‘, ‘sdd‘, [‘bb‘, ‘aa‘]] # append是往元素的最後添加,extend是打開列表擴展
append和extend 的區別