【问题标题】:Executable runs differently depending on where it is launched from可执行文件的运行方式不同,具体取决于它从哪里启动
【发布时间】:2016-04-04 08:25:42
【问题描述】:

我使用 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 

【问题讨论】:

    标签: python-2.7 cmd executable


    【解决方案1】:

    如果您运行的是 Windows,则可能需要安装 Ansicon。此链接可能对您有用:Colorama for Python, Not returning colored print lines on Windows

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-01
      相关资源
      最近更新 更多