書名: Mastering Python Scripting for System Administrators作者名: Ganesh Sanjiv Naik本章字數: 55字更新時間: 2021-07-02 14:00:20
Accessing values in strings
We can access characters from strings using slicing by using square brackets. We can also access characters from strings between the specified range. Refer to the following example:
#!/usr/bin/python3
str1 = 'Hello Python!'
str2 = "Object Oriented Programming"
print ("str1[0]: ", str1[0])
print ("str2[1:5]: ", str2[1:5])
Output:
str1[0]: H
str2[1:5]: bjec
推薦閱讀
- Learn Type:Driven Development
- Wireshark Network Security
- Mastering AndEngine Game Development
- Nginx Essentials
- Windows Forensics Cookbook
- 3D少兒游戲編程(原書第2版)
- 執劍而舞:用代碼創作藝術
- Learning AWS
- Unity Character Animation with Mecanim
- Python自然語言理解:自然語言理解系統開發與應用實戰
- Java EE項目應用開發
- iOS Development with Xamarin Cookbook
- 現代C++語言核心特性解析
- Scratch少兒編程高手的7個好習慣
- 3ds Max瘋狂設計學院