書名: Mastering Python Scripting for System Administrators作者名: Ganesh Sanjiv Naik本章字數: 64字更新時間: 2021-07-02 14:00:24
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)
推薦閱讀
- 手機安全和可信應用開發指南:TrustZone與OP-TEE技術詳解
- SPSS數據挖掘與案例分析應用實踐
- Microsoft Exchange Server PowerShell Cookbook(Third Edition)
- Docker技術入門與實戰(第3版)
- MySQL 8從入門到精通(視頻教學版)
- Apache Hive Essentials
- 編寫高質量代碼:改善Python程序的91個建議
- Functional Kotlin
- AutoCAD VBA參數化繪圖程序開發與實戰編碼
- 從0到1:Python數據分析
- Mastering JBoss Enterprise Application Platform 7
- 零基礎入門學習Python(第2版)
- 利用Python進行數據分析
- Android Studio開發實戰:從零基礎到App上線 (移動開發叢書)
- TensorFlow.NET實戰