Python3 List insert()方法

Python 3 教程 · 2019-02-06 13:11:32

描述

insert() 函数用于将指定对象插入列表的指定位置。

语法

insert()方法语法:

list.insert(index, obj)

参数

  • index -- 对象obj需要插入的索引位置。
  • obj -- 要插入列表中的对象。

返回值

该方法没有返回值,但会在列表指定位置插入对象。

实例

以下实例展示了 insert()函数的使用方法:

#!/usr/bin/python3

list1 = ['Google', 'Codercto', 'Taobao']
list1.insert(1, 'Baidu')
print ('列表插入元素后为 : ', list1)

以上实例输出结果如下:

列表插入元素后为 :  ['Google', 'Baidu', 'Codercto', 'Taobao']

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

Real-Time Collision Detection

Real-Time Collision Detection

Christer Ericson / CRC Press / 2004-12-22 / USD 98.95

Written by an expert in the game industry, Christer Ericson's new book is a comprehensive guide to the components of efficient real-time collision detection systems. The book provides the tools and kn......一起来看看 《Real-Time Collision Detection》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具