单选题 适中
#15602

执行以下Python代码后,输出的结果是? ( ) s = " PyThon5级! " result = s.strip().lower().find('tho…

执行以下Python代码后,输出的结果是? ( )

s = " PyThon5级! "
result = s.strip().lower().find('thon')
print(result)
未登录也能判分,登录后才会记录
答案与解析
正确答案:A
解析

strip() 移除两端空格,得到 "PyThon5级!";lower() 转为小写,得到 "python5级!";find('thon') 在 "python5级!" 中查找子串 "thon",起始索引为 2(p的索引是0,y是1,t是2)。