索引,下标,获取字符中的某一个字符
test = "alex" v = test[0:1] #显示的是第0号<=1号字符 print(v)
一行字竖行循环分开
test = "水果啥的广东省公司的发生" index = 0 while index < len(test): v = test[index] print(v) index += 1 print(‘====‘)
替换
test = "水果啥的广东省公司的发生" v = test.replace(‘的‘,‘1‘) print(v)
创造连续/不连续数字,定位循环
test = input(‘请输入‘) print(test) l = len(test) print(l) r = range(0,l) for item in r: print(item,test[item])
原文:https://www.cnblogs.com/wangleiyifan/p/9147738.html