python str.find 方法

str.find用于寻找字符串中的字串的最近位置。如果没有则返回-1

    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
s='DIV2K'
print(s.find('DIV2K'))

猜你喜欢

转载自blog.csdn.net/qq_40107571/article/details/127341380