前言 Front Matter Contents 1. 开胃菜 Whetting Your Appetite 2. 使用Python解释器 Using the Python Interpreter 2.1 调用解释器 Invoking the Interpreter 2.1.1 参数传递 Argument Passing 2.1.2 交互模式 Interactive Mode 2.2 解释器及其环境 The Interpreter and Its Environment 2.2.1 错误处理
Python数据类型:list
list 是一种有序集合,由于Python是动态语言,所以 list 中包含的元素并不要求都必须是同一种数据类型,我们完全可以在 list 中包含各种数据。
访问列表中最后一个元素:L[-1],索引值为 -1。同理倒数第二个元素索引值为 -2,以此类推。
list 中添加元素,第一个办法是用 list 的 append() 方法,把新同学追加到 list 的末尾。另一种方法是用list的 insert()方法,它接受两个参数,第一个参数是索引号,第二个参数是待添加