py2app 应用程序中的捆绑文本文件(python) [英] Bundle Text file in py2app Application (python)
问题描述
我最近学习了 Python (2.7),并且一直在用 AI 制作一些简单的棋盘游戏,例如练习.我目前正在制作一个需要包含字典文件的智能刽子手游戏.(我有一个文本文件,每行都有一个新词).我成功地将 py2app 用于其他内容,例如:connect-four.zzl.org 但不幸的是,它没有当我为我的新刽子手程序运行 py2app 时,似乎没有包含我的文本文件.谁能帮我弄清楚如何包含这个文件,以便程序可以像我链接的连接四游戏一样分发?
I recently learned Python (2.7) and have been making some simple board games with AIs and such as practice. I am currently making an intelligent hangman game which necessitates the inclusion of a dictionary file. (I have a text file which has a new word on each line). I used py2app successfully for other stuff such as this: connect-four.zzl.org but unfortunately, it doesn't seem to include my text file when I run py2app for my new hangman program. Can anyone help me figure out how to include this file so that the program can be distributed like the connect four game I linked to?
非常感谢.(我运行的是 OS X 10.7,如有必要,可以提供任何其他必要的信息)
Thank You very much. (I am running OS X 10.7 and can provide any other necessary info if necessary)
推荐答案
在包含要包含的资源列表的选项中指定一个资源键.这将是您的应用程序运行时的当前目录
Specify a resources key in your options that contains a list of resources to include. This will be the current directory when your app runs
options = { "resources": ["myfile.txt"] }
options = { "resources": ["myfile.txt"] }
http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#option-reference
如果您在 py2applet 中使用资源标志,它将创建该密钥
If you use the resources flag with py2applet it will creates that key
这篇关于py2app 应用程序中的捆绑文本文件(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!