04-find vs index:找不到时差异
语法讲解
今天学: find / index 的差异
s = "hello"
print(s.find("x"))
try:
print(s.index("x"))
except Exception as e:
print(type(e).__name__)
小练习
运行下面代码后输出是什么?(多行输出请按真实换行提交)
s = "hello"
print(s.find("x"))
try:
print(s.index("x"))
except Exception as e:
print(type(e).__name__)
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论