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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章