• Как разбить строки на слова?

    @throughtheether
    human after all
    Такой вариант подойдет?
    SEPARATORS=",.;?! "
    def toster_word_split(s):
        result=[]
        current_word=''
        for char in s:
            if char in SEPARATORS:
                if current_word: result.append(current_word)
                current_word=''
            else:
                current_word+=char
        return result
    print toster_word_split("Lorem,ipsum;bingo.Bongo? King of Kongo.")
    Ответ написан
    Комментировать