小编Avn*_*esh的帖子

为什么rfind和find在Python 2.6.5中返回相同的值?

我对Python比较陌生,有些东西正在起作用.基本上,当我调用str.rfind("test")字符串时,输出与...相同str.find("test").我最好向您展示一个例子:

Python 2.6.5 (r265:79063, May  6 2011, 17:25:59) 
[GCC 4.5.0 20100604 [gcc-4_5-branch revision 160292]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> line = "hello what's up"
>>> line.rfind("what")
6
>>> line.find("what")
6
Run Code Online (Sandbox Code Playgroud)

根据我的理解,价值line.find是可以的,但价值line.rfind应该是9.我是否误解了这些功能或者没有很好地使用它们?

python substring find

8
推荐指数
2
解决办法
9841
查看次数

标签 统计

find ×1

python ×1

substring ×1