Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的脚本:
current_directory=os.path.abspath(os.curdir) self.image_array = glob.glob(os.path.join(current_directory,"./data/world_flag_game/flags/*.png")
当我从终端运行它(快速使用)时,这工作正常,但是当我打包它(使用快速包)时,路径似乎不起作用。
如果路径不起作用,则可能不是 .png 图像所在的路径。尝试从终端以及打包的应用程序打印路径。以下内容将帮助您了解为什么找不到图像。
print("%r" % current_directory)
应用程序的构建目录与其开发目录不同也就不足为奇了。因此,您可能希望将您的替换os.path.join(...)为绝对目录,以验证您的应用程序在打包时是否正常工作。然后将图像存储到构建目录中,然后正确指向该位置。
os.path.join(...)