Index
我们可以用square bracket[ ]里Index去提取string中的任意字符
index value是从零开始的整数
如果你试图index超过字符串长度的值,会报错
Lenth
len()计算字符串的长度
Looping Through Strings
while
用while statement、iteration variable和len function构建循环,去查看string里的每一个字母
fruit = 'banana'
index = 0
while index < len(fruit):
print(fruit[index] , index)
index = index + 1
for
更简单,就是用for … in …把,字符串遍历一遍并输出
fruit = 'banana'
for letter