You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyDictionary调用meaning方法始终返回空字典问题求助

PyDictionary调用meaning方法始终返回空字典问题求助

我最近在做一个Python项目时导入了PyDictionary库,但不管用哪个单词调用meaning()函数,它都只返回空字典。以下是我目前的脚本:

# Import Libraries
from tkinter import *
from gtts import gTTS
from PyDictionary import PyDictionary
import random

# Create Functions
def chooserandom(list: list):
    return list[random.randrange(0, len(list))]

# Create Variables
words: list[str] = "".join(list(open("word-lists\\mainlist.txt", "r"))).split("\n")
dictionary = PyDictionary()

# Main Loop
word: str = chooserandom(words)
definition = dictionary.meaning(word)
print(word) # amber
print(definition) # {}
  • word-lists\\mainlist.txt是一个存储英文单词的文本文件
  • print(word)可以正常工作,会随机打印文件里的一个单词(比如"amber")
  • 但print(definition)总是输出{}

有没有大佬能给点解决思路或者建议呀?非常感谢!

备注:内容来源于stack exchange,提问作者caiamari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 16:38:05