import nltk
from nltk.tokenize import sent_tokenize, word_tokenize
sentence = """At eight o'clock on Thursday morning
Arthur didn't feel very good."""
a=word_tokenize(sentence)
if a[3] == 'on'
print a
答案 0 :(得分:2)
语法错误,您在if
条件后忘记了冒号:
if a[3] == 'on':
print a
我得到了这个输出:
['At', 'eight', "o'clock", 'on', 'Thursday', 'morning', 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']