码迷,mamicode.com
首页 > 其他好文 > 详细

字符串find

时间:2018-10-29 14:12:20      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:print   index   where   bst   找不到   option   eal   ati   hat   

    def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """
        S.find(sub[, start[, end]]) -> int
        
        Return the lowest index in S where substring sub is found,
        such that sub is contained within S[start:end].  Optional
        arguments start and end are interpreted as in slice notation.
        
        Return -1 on failure.
        """
        return 0
name="wesley hello world wesley wesley"
ret=name.find(he,2,8)
print(ret)         #找不到返回-1
ret=name.find(e)
print(ret)  #找到返回索引

-1
1

 

字符串find

标签:print   index   where   bst   找不到   option   eal   ati   hat   

原文地址:https://www.cnblogs.com/wuxi9864/p/9870140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!