
上QQ阅读APP看书,第一时间看更新
4.1.5 列表的4个函数
列表的4个函数的名称及功能说明如表4.1所示。
表4.1 列表的函数名及功能说明

列表的函数示例如下。
单击“开始”菜单,打开Python 3.6.5 Shell软件,然后在菜单栏中选择File→New File命令,创建一个Python文件,并命名为Python4-4.py,然后输入以下代码:

在这里用到了元组。需要注意的是,元组与列表是非常相似的,区别在于元组的元素值不能修改,元组是放在括号中,列表是放在中括号中。
在菜单栏中选择Run→Run Module命令或按键盘上的F5键,就可以运行程序代码,结果如图4.4所示。

图4.4 列表的函数示例的运行结果