python append()
>>> A = ['q','w','e','r']>>> A.extend(['t','y'])>>> A
['q','w','e','r','t','y']>>>len(A)6>>> B = ['q','w','e','r']>>> B.append(['t','y'])>>> B
['q','w','e','r', ['t','y']]>>>len(B)5
extend與append方法的相似之處在於都是將新接收到引數放置到已有列表的後面。而extend方法只能接收list,且把這個list中的每個元素新增到原list中。
而append方法可以接收任意資料型別的引數,並且簡單地追加到list尾部。
>>> a = [11,22,33]>>> a.extend([44])>>> a
[11,22,33,44]>>> a.extend('55')>>> a
[11,22,33,44,'5','5']#因為extend只接收list,所以將其拆分
相關文章
- 【Python有坑系列】numpy.append中有坑PythonAPP
- URLSearchParams append()APP
- URLSearchParams append() 方法APP
- Python3中列表方法append()和extend()的區別PythonAPP
- 【廖雪峰python入門筆記】list新增元素_append()和insert()Python筆記APP
- [Bash] Append the content at the beginning of the fileAPP
- jQuery的append和appendTojQueryAPP
- Python之列表的append()方法最容易踩的坑及解決PythonAPP
- python迴圈遍歷字典: title_content_list.append([key, value])print(tiPythonAPP
- alter table nologging /*+APPEND PARALLEL(n)*/APPParallel
- SAP ABAP Append structure 介紹APPStruct
- [golang]slice的坑:從append到共享GolangAPP
- 列表中的append,extend,+=,+的區別APP
- v-html 及vue-append外掛HTMLVueAPP
- 問下append後地址不一樣了APP
- pandas中如何使用合併append函式?APP函式
- 編寫函式:遞迴求逆序 (Append Code) ★函式遞迴APP
- jquery中append()方法與after()方法的區別jQueryAPP
- go中陣列,切片和append的玄學Go陣列APP
- 問題解決:AttributeError: ‘NoneType‘ object has no attribute ‘append‘ErrorNoneObjectAPP
- jquery中append、prepend, before和after方法的區別jQueryAPP
- 當我呼叫了$().append()後,jQuery內部發生了什麼?APPjQuery
- [提問交流]關於Jquery Append鉤子的問題,大神求助!jQueryAPP
- Storage::append 存日誌,追加儲存到 1M 左右 就被清空了APP
- Go 常見錯誤集錦之 append 操作 slice 時的副作用GoAPP
- 整明白 Golang slice 宣告方式、淺複製現象、深複製、append操作GolangAPP
- 通過append hint來插入資料,演示它和普通插入資料的效能比較。APP
- PostgreSQL 原始碼解讀(102)- 分割槽表#8(資料查詢路由#5-構建APPEND訪問路徑)SQL原始碼路由APP
- PostgreSQL 原始碼解讀(103)- 分割槽表#9(資料查詢路由#6-APPEND初始化和實現)SQL原始碼路由APP
- [新包] 根據 appends 配置的欄位對映關係,自動維護需要的 appends - Laravel Eloquent Append AutomationAPPLaravel
- 【新包】根據 appends 配置的關聯欄位對映關係,自動維護需要的 appends - Laravel Eloquent Append AutomationAPPLaravel
- 【python】python安裝Python
- python ----python的安裝Python
- python:python的多程式Python
- python--- 之The program 'python' can be found in the following packages: * python-minimal * python3PythonPackage
- Python IDLE和Python的區別!Python入門教程Python
- python學習之初識pythonPython
- 【Python】python類的繼承Python繼承