Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Kivy app中将json文件用作存储时,对.json文件的权限被拒绝_Python_Json_Kivy - Fatal编程技术网

Python 在Kivy app中将json文件用作存储时,对.json文件的权限被拒绝

Python 在Kivy app中将json文件用作存储时,对.json文件的权限被拒绝,python,json,kivy,Python,Json,Kivy,我试图在JsonStore文件中存储一个值,但单击按钮时出现以下错误: 文件“C:\utils\kivy\kivy\kivy\storage\jsonstore.py”,第39行,在 存储同步 将open(self.filename,'w')作为fd:PermissionError:[Errno 13]权限被拒绝:“storage.json” 使用Kivy的user_data_dir自动确定用户数据存储在不同设备上的位置,然后传递要存储的文件的完整路径 from kivy.storage.jso

我试图在JsonStore文件中存储一个值,但单击按钮时出现以下错误:

文件“C:\utils\kivy\kivy\kivy\storage\jsonstore.py”,第39行,在 存储同步 将open(self.filename,'w')作为fd:PermissionError:[Errno 13]权限被拒绝:“storage.json”


使用Kivy的user_data_dir自动确定用户数据存储在不同设备上的位置,然后传递要存储的文件的完整路径

from kivy.storage.jsonstore import JsonStore
from os.path import join

data_dir = App().user_data_dir
store = JsonStore(join(data_dir, 'storage.json'))

尝试传递文件的完整路径-根据您执行脚本的方式,您的用户可能无权写入目录。@Burhan Khalid-非常感谢,它使用完整路径工作(我正在电脑上测试)。将尝试部署到手机上,看看是否可以在没有完整路径的情况下运行它。
from kivy.storage.jsonstore import JsonStore
from os.path import join

data_dir = App().user_data_dir
store = JsonStore(join(data_dir, 'storage.json'))