gpt4 book ai didi

python - 在 ios 上的 kivy 应用程序中写入/保存文件的问题

转载 作者:行者123 更新时间:2023-11-28 23:48:05 24 4
gpt4 key购买 nike

我正在使用 kivy 框架制作游戏。为了保存高分,我在我的 App 类中使用了这一行:

def build(self):
save_file = open("save.txt", "r")
sm.get_screen('menu').set_score(int(save_file.readlines()[0]))
save_file.close()
return sm

def on_stop(self):
save_file = open("save.txt", "w")
save_file.write(str(sm.get_screen('menu').high_score))
save_file.close()

当我在 python 中运行它时,一切正常,但是当我在模拟器或物理设备上运行它时,它似乎没有保存。当保存文件中的数字为 55 时,它会读取它。

我在 xcode 上运行它时得到了该日志:

    2018-09-12 20:57:05.940676+0200 decode[18245:457744] [Common] 
_BSMachError: port 6707; (os/kern) invalid capability (0x14)
"Unable to insert COPY_SEND"
2018-09-12 20:57:05.941114+0200 decode[18245:457744] [Common] _BSMachError: port 6707; (os/kern) invalid capability (0x14)
"Unable to insert COPY_SEND"

这是项目:https://github.com/KarolBorecki/Decode

谢谢大家的帮助!

最佳答案

我不做 ios 开发,但我很确定你不能写入其中的任意位置。我认为您可以使用 App.user_data_dir 属性来获取可以持久写入的路径。

关于python - 在 ios 上的 kivy 应用程序中写入/保存文件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52301798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com