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

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)

主站蜘蛛池模板: 疏附县| 乌什县| 宁安市| 东乡族自治县| 宿松县| 鹿邑县| 内江市| 濮阳市| 巴彦县| 河池市| 高安市| 阿巴嘎旗| 壤塘县| 曲沃县| 长武县| 阿拉尔市| 灵璧县| 临澧县| 九龙县| 饶平县| 阿合奇县| 湖北省| 长沙市| 城口县| 永顺县| 昌乐县| 诸暨市| 拜泉县| 枣庄市| 蒙山县| 枞阳县| 大连市| 汉中市| 平度市| 九寨沟县| 类乌齐县| 吉林省| 盘锦市| 永和县| 丹江口市| 眉山市|