- 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
推薦閱讀
- HTML5+CSS3+JavaScript從入門到精通:上冊(微課精編版·第2版)
- AngularJS入門與進階
- Maven Build Customization
- SQL語言從入門到精通
- Instant Typeahead.js
- Spring Cloud、Nginx高并發核心編程
- Hands-On C++ Game Animation Programming
- Mastering AndEngine Game Development
- KnockoutJS Starter
- 程序是怎樣跑起來的(第3版)
- Haxe Game Development Essentials
- Solr Cookbook(Third Edition)
- 0 bug:C/C++商用工程之道
- HTML5+CSS3+JavaScript 從入門到項目實踐(超值版)
- Using Yocto Project with BeagleBone Black