以下代码属于 NLTK 正则表达式:
import nltk
nltk.download('punkt')
from nltk.tokenize import word_tokenize
from nltk.tokenize import sent_tokenize
scene = "Hello how! how are you? what is your problem. Can I solve with 00code for you/ by the way bye. Take care"
match_index = print(re.search("you",scene))
print(match_index.start(),match_index.end())
我得到的错误是:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-54-5e13e5437c3e> in <module>()
----> 1 print(match_index.start(),match_index.end())
AttributeError: 'NoneType' object has no attribute 'start'
我已经包含了它的库,但它仍然显示错误。我有什么方法可以处理这个错误?