首页 > 解决方案 > 无法从“termcolor”导入名称“colored”

问题描述

我正在尝试使用 termcolor 教程在 python3 中使用 termcolor,但我无法从 termcolor 导入颜色

from termcolor import colored
text = colored("Hello world", "green")
print(text)

它给了我

E:\>python termcolor.py
Traceback (most recent call last):
  File "termcolor.py", line 1, in <module>
    from termcolor import colored
  File "E:\termcolor.py", line 1, in <module>
    from termcolor import colored
ImportError: cannot import name 'colored' from 'termcolor' (E:\termcolor.py)

标签: pythontermcolor

解决方案


推荐阅读