实际上是通过编号对数组进行引用,第四章的字典则是通过名字引用
列表可以修改 元组不能修改
按编号获取元素
test="hello world"PRint test[0] #获取第1个元素print test[-1]#获取倒数第一个元素输出结果
hdPress any key to continue . . .输出结果
helello worlello worldel olPress any key to continue . . .输出结果
[1, 2, 3, 4, 5, 6]helloworldPress any key to continue . . .输出结果
[1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]hellohellohellohellohelloPress any key to continue . . .输出结果
TrueFalsePress any key to continue . . .输出结果
441Press any key to continue . . .输出结果
['h', 'e', 'l', 'l', 'o']Press any key to continue . . .输出结果
[1, 4, 3]['a', 'b']['a', 'a', 's', 'd']['a', 'a', 's', 'd', 'a', 's', 'd']['a']Press any key to continue . . .输出结果
[1, 2, 3, 2]421[1, 2, 3, 4, 5]3[1, 2, 3, 'as', 4, 2, 12, 3, 1, 1, 1]2[1, 2, 3, 4, 2, 12, 3, 1, 1][1, 2, 4, 2, 12, 3, 1, 1, 2][2, 1, 1, 3, 12, 2, 4, 3, 2, 1][1, 1, 1, 2, 2, 2, 3, 3, 4, 12][1, 1, 1, 2, 2, 2, 3, 3, 4, 12]1-1Press any key to continue . . .输出结果
1 2 3(1, 2, 3)()(2,)10(5, 5)(1, 2, 3)('a', 's')Press any key to continue . . .新闻热点
疑难解答