首页 > 技术文章 > 字符串find

wuxi9864 2018-10-29 13:20 原文

    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

 

推荐阅读