Я пытаюсь получить файл для ввода и поиска специального символа.Я даю от и до клавиш в качестве ввода.если ключевое слово to находится в следующей строке, я должен напечатать, пока ключевое слово to не будет найдено.
for line in contents:
if line.startswith("*CHI: ") :
line = line.strip("*")
tokenize = line.split()
p.token_filter(tokenize)
скажем, у меня есть файл:
*CHI: (hi) new [/] friend [//] there [/-] [ bch] [ bch ] /[]/ [/=]
<new>
<there>.
%mod: hi there.
*CHI: <dude>
<there>
*CHI: &=sighs <and instead the> [//] and then the gira?e got it and gave it to the elephant .
*CHI: <he> [/] <he> [/] he hold it .
*CHI: then [/-] the doctor give the [/] money to the man
*CHI: and (i)s then (.) the little (.) gira?e is crying because it (i)s sinking
Используя приведенный выше код, яполучить вывод следующим образом:
['new', '[/]', 'friend', '[//]', 'there', 'bch', '/[]/']
['dude', 'dude']
['and', 'and', 'instead', 'the', 'the', '[//]', 'and', 'then', 'the', 'gira?e', 'got', 'it', 'and', 'gave', 'it', 'to', 'the', 'elephant', '.']
['he', 'he', '[/]', 'he', 'he', '[/]', 'he', 'hold', 'it', '.']
['then', 'the', 'doctor', 'give', 'the', '[/]', 'money', 'to', 'the', 'man']
['and', 'then', '(.)', 'the', 'little', '(.)', 'gira?e', 'is', 'crying', 'because', 'it', 'sinking']
Моя другая цель - я должен напечатать ['new', '[/]', 'friend', '[//]', 'there', 'bch',' / [] / '' new '' there ''. ']