【发布时间】:2020-07-05 00:33:53
【问题描述】:
我试图了解如何将config.py 文件与一个非常基本的应用程序一起使用,该应用程序允许config.py 文件位于已编译的 .exe 应用程序之外。
这是我的文件结构。
/ config.py
/ sayhello.py
[sayhello.py]
import config as config
if __name__ == "__main__":
print (config.CHARACTERS['PLAYER_1'] + ", I'd like for you to meet " + config.CHARACTERS['PLAYER_2'] + ".")
print (config.CHARACTERS['PLAYER_2'] + ", this is your cousin " + config.CHARACTERS['PLAYER_1'] + ".\n")
[config.py]
# Define player names
CHARACTERS = {
'PLAYER_1': "Abby",
'PLAYER_2': "Billy"
}
我在 Visual Studio Code 中运行脚本,输出如下所示。
Abby, I'd like for you to meet Billy.
Billy, this is your cousin Abby.
我运行pyinstaller sayhello.py 并且我有一个应用程序的构建/分布。我执行sayhello.exe,输出如预期的那样,太棒了。
Abby, I'd like for you to meet Billy.
Billy, this is your cousin Abby.
config.py 文件在哪里供我编辑以便我可以更改角色名称?
【问题讨论】:
标签: python configuration