我用Python 2.7创建了一个游戏,并且在将其转换为可执行文件后运行它时遇到了一些问题。如果我通过cmd切换到目录,它允许我使用已应用的所有格式运行它,如下所示:
如果我选择通过简单地执行游戏来访问它,它似乎正在读取类中包含反斜杠颜色的不同实体作为字符串。
提供信息的班级如下,
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
通用代码如下所示:
print bcolors.FAIL + ("Try combining the cd command and room you want to enter") + bcolors.END
答案 0 :(得分:0)
If you are running Windows, you may need to install Ansicon. This link will probably be of use to you: Colorama for Python, Not returning colored print lines on Windows