发布时间:2017-11-20 18:06:10编辑:Run阅读(5825)
访问列表中的元素,使用下标的方式,通常以0开始(为什么是0而不是1),这里程序的设计就是如此,个人觉得没有必要纠结,如有兴趣,可自行查看资料
实验代码如下
# coding: utf-8
__author__ = 'www.py3study.com'
lists = ['one', 'two', 'three', 'four', 'five']
print("打印第一个数:{}".format(lists[0]))
print("打印第二个数:{}".format(lists[1]))
print("打印第三个数:{}".format(lists[2]))
print("打印第四个数:{}".format(lists[3]))
print("打印第五个数:{}".format(lists[-1]))
应该看到的结果
上一篇: 习题30:While循环
下一篇: 习题32:分支和函数(函数调用函数)
48000
46616
37563
34919
29482
26131
25085
20111
19738
18210
5920°
6577°
6082°
6084°
7197°
6026°
6113°
6585°
6553°
7938°