1 a = "hello"
2 a1 = a[1]
3 a2 = a[0:2]
4 print(a1)
5 print(a2)

我们通过索引获取字符串中指定位数的字符

通过切片获取指定区间范围的所有字符 范围大于等于开始小于末尾

相关文章: