python - 无法在 python 中使用 langdetect 包

标签 python

我正在尝试使用 langdetect 包检测字符串的语言。但它不起作用。

from langdetect import detect

word_string = "Books are for reading"
print(detect(word_string))

如果我使用上面的代码,我会收到错误ImportError:无法导入名称检测

当我用*替换检测时

from langdetect import *

word_string = "Books are for reading"
print(detect(word_string))

我收到错误:NameError:名称“检测”未定义

所以我的问题是如何解决这些问题?

所以问题是我的 langdetect 包和 python 文件同名......谢谢您的回答。

最佳答案

首先尝试通过编写以下内容来安装它:-> !pip install langdetect 在终端上 然后导入langDetect

关于python - 无法在 python 中使用 langdetect 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46367625/

相关文章:

python - 如何根据当前 URL 中的 ID 过滤 ListView 输出

线程内的 Python DBusGMainLoop 和 try and catch block

python - 如何根据 Python 中另一个数据框的关系为变量赋值

python - 如何绘制特定的函数?

Python从列表a中查找列表b中的项目索引

python - OpenCV Pawn 棋子没有检测到?

python - docker 化时 pip 要求不匹配

python - 将纹理映射到 mayavi 网格

python - pyqt5 应用程序中对话框和主窗口的国际化(翻译)

python - 如何使用 python-docx 在文本中设置语言