python中colorama中Fore的导入

2024-05-14 19:14:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python中尝试Colorama,我导入了Colorama,然后启动了它,因为我使用的是64位Windows 7。但不知怎的,在从Colorama导入前、后、样式之后,当我在命令提示符下运行该程序时,它显示了-Import错误,表示“无法从Colorama导入名称'Fore'”! 我给出了我键入的代码和屏幕截图,以及从命令提示符中得到的错误。 :-)

> Code:

import colorama
from colorama import Fore, Back, Style
colorama.init()
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

Error in the command prompt

(base) PS *** python colorama.py
Traceback (most recent call last):
File "colorama.py", line 1, in <module>
import colorama
File ***, line 2, in <module>
from colorama import Fore, Back, Style
ImportError: cannot import name 'Fore' from 'colorama' ***

星号(*)屏蔽目录

That is the screenshot of the code(on right-hand-side) and error(on left-hand side). The white filled boxes reveal the directories and hence masked


Tags: andthetextinfrompyimportstyle

热门问题