Python 3 教程教程
Python3 List append()方法
Python3 List append()方法
Python3 List append()方法
描述
append() 方法用于在列表末尾添加新的对象。
语法
append()方法语法:
list.append(obj)
参数
- obj -- 添加到列表末尾的对象。
返回值
该方法无返回值,但是会修改原来的列表。
实例
以下实例展示了 append()函数的使用方法:
#!/usr/bin/python3 list1 = ['Google', 'verydoc', 'Taobao'] list1.append('Baidu') print ("更新后的列表 : ", list1)
以上实例输出结果如下:
更新后的列表 : ['Google', 'verydoc', 'Taobao', 'Baidu']
Python3 List append()方法 |
---|
Python 3 教程
Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。