字符串方法适用场景
2021年04月24日10:25:19
name="alex lenb"
#请输出name变量对应的值中“e”所在索引位置?
index=0 #手动记录一下索引
for c in name:
if c=='e':
print(index)
index = index+1
---------------------------
s="123a4b5c"
#有字符串s="123a4b5c"
#1)通过对s切片,形成新的字符串s1,s2="123"
print=(s[:3])
#通过对s切片形成新的字符串s1 s2="a4b"
print(s[3:6])
---------------------------
s="321"
for c in s:
print("倒计时%s秒"%c)
else:
print("出发")

浙公网安备 33010602011771号