官术网_书友最值得收藏!

Accessing values in tuples

To access values in a tuple, use the square brackets for slicing along with the index or indices to obtain the value available at that index or indices, as shown in the following example:

#!/usr/bin/python3
cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')
numbers = (1, 2, 3, 4, 5, 6, 7)
print (cities[3])
print (numbers[1:6])

Output:
Pune
(2, 3, 4, 5)

主站蜘蛛池模板: 河间市| 颍上县| 张北县| 鄄城县| 淅川县| 梅河口市| 东至县| 三都| 灵山县| 金门县| 乌鲁木齐市| 财经| 唐河县| 博客| 德化县| 清涧县| 仙居县| 白河县| 垣曲县| 临澧县| 吴桥县| 大悟县| 大英县| 涞水县| 蓬莱市| 江油市| 张掖市| 环江| 扶绥县| 洪湖市| 钟祥市| 平陆县| 陈巴尔虎旗| 安阳市| 资中县| 呼和浩特市| 来宾市| 定陶县| 镇宁| 汉寿县| 延边|