1
我使用pyenchant来检查输入是否是英文单词。我想显示一条消息,如果它是"It is a real word"
,如果不是,则显示"It's not a real word"
。我知道我必须使用d.check
,但我该如何处理真假的条件如果使用pyenchant的输入是英语单词,而不是当它不是时,你如何打印语句?
我使用pyenchant来检查输入是否是英文单词。我想显示一条消息,如果它是"It is a real word"
,如果不是,则显示"It's not a real word"
。我知道我必须使用d.check
,但我该如何处理真假的条件如果使用pyenchant的输入是英语单词,而不是当它不是时,你如何打印语句?
你可以试试这个。检查函数返回一个布尔值,您可以将其放入if语句中:
import enchant
d = enchant.Dict("en_US") # create dictionary for US English
if d.check("enchant"): # or any word
print("It is a real word")
else:
print("Its not a real word")
非常感谢你 –
如果它有效,请考虑接受答案 –