python自学第四课!

replace()替换字符串

test = 'starararar'
v = test.replace('ar','bb',2)
print(v)

结果:stbbbbarar

将输入的字符串的索引打印出来

test1 = input(">>>")

for a in range(0,len(test1)) :
    print(a,test1[a])

猜你喜欢

转载自www.cnblogs.com/starz224/p/9120962.html