vegas#True

    def findLocation(self, rule: dict, result: str):

        if rule['find'] not in result:
            return False

        findIndex = result.index(rule['find'])
        locationIndex = result.index(rule['location'])

        locationDesc = ''
        if findIndex > locationIndex:
            # location 在前
            locationDesc = f"{result[:findIndex].count(' ') + 1}位{rule['location']}"
        else:
            # location 在后
            locationDesc = f"{result[:findIndex].count(' ') + 2}位{rule['location']}"
        return locationDesc

你可能感兴趣的:(control)