字符串是字符的有序集合,可以通过其位置来获得具体的元素。在 python 中,字符串中的字符是通过索引来提取的,索引从 0 开始
python 可以取负值,表示从末尾提取,最后一个为 -1,倒数第二个为 -2,即程序认为可以从结束处反向计数
0 1 2 3 4 5
s t r i n g
-6 -5 -4- -3 -2- -1
str3='The flower is so beautiful'
print(str3[0:10]) ### 取从0至9的字符串
The flower
print(str3[-5:]) ### 取从倒数第5至结尾的字符串
tiful
print(str3[::]) ### 复制字符串
The flower is so beautiful
### 字符串相乘
line='#'*50
print(line)
##################################################