Python。我想找出下列程序中的错误

2024-04-20 07:12:25 发布

您现在位置:Python中文网/ 问答频道 /正文

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

Tags: fromimportonsentenceatwordsenttokenize
1条回答
网友
1楼 · 发布于 2024-04-20 07:12:25

语法错误,您在if条件后忘记了冒号:

if a[3] == 'on':
    print a

我得到了这个输出:

['At', 'eight', "o'clock", 'on', 'Thursday', 'morning', 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']

相关问题 更多 >