为什么输出是4? [英] Why the output is 4?

查看:87
本文介绍了为什么输出是4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道为什么输出是4?





I wonder Why the output is 4?


word = "banana"
index = word.find("na", 3)
print(index)

推荐答案

http://www.tutorialspoint.com/python/string_find.htm [ ^ ]



http://www.tutorialspoint.com/python/string_find.htm[^]

banana
012345
   >^





你要求从偏移量3开始的第一个na实例 - 那是在偏移量4处。



You asked for the first instance of "na" starting from offset 3 -- and that's at offset 4.


这篇关于为什么输出是4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆