文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Python - List

Python - List

时间:2010-08-19  来源:AllenW

1. Difinition

ListTest=["Value1","Value2","Vaule3"]

Note:

    1)It is included by []

    2)Divied by comma

 

2.Usage

>>> ListTest
[
'Value1', 'Value2', 'Value3']
>>> ListTest[0]
'Value1'
>>> ListTest[2]
'Value3'

Note:The ordinal number is increased from 0 to n-1

>>> ListTest[-1]
'Value3'
>>> ListTest[-3]
'Value1'

Note:The ordinal number is decreased from -1 to -n

 

3. Basic Operation

    1)append

>>> ListTest.append("Value4")
>>> ListTest
[
'Value1', 'Value2', 'Value3', 'Value4']

    2)insert

>>> ListTest.insert(2,"two")
>>> ListTest
[
'Value1', 'Value2', 'two', 'Value3', 'Value4']
>>> ListTest[2]
'two'

    3)extend

>>> ListTest2=['Value21','Value22']
>>> ListTest2
[
'Value21', 'Value22']
>>> ListTest.extend(ListTest2)
>>> ListTest
[
'Value1', 'Value2', 'two', 'Value3', 'Value4', 'Value21', 'Value22']

 

 

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载