如何在QPython for android上使用gdata并保存文件?

时间:2021-04-16 20:20:57

I am in the process of migrating my scripts from python SL4A to QPython (can't get SL4A to work on android lollipop).

我正在将我的脚本从python SL4A迁移到QPython(无法让SL4A在android lollipop上运行)。

I can't save a file to the disk
So I am using:

我无法将文件保存到磁盘所以我正在使用:

with open("foo.txt" ,"a") as f:
    f.write(theInfo)

And I get

我明白了

IOError: [Errno 30] Read-only file system: 'foo.txt'

I know what the error means, I just don't know where to save the file...

我知道错误意味着什么,我只是不知道保存文件的位置......

Thanks for the help,
marbs

谢谢你的帮助,marbs

2 个解决方案

#1


The error is saying that you are in a protected part of a file system. That means you may want to save the file in an un-protected part. So, you may want to replace the "foo.txt" part with "/mnt/sdcard/foo.txt" or "/storage/sdcard0/foo.txt" or whatever is the path of internal storage on your phone. Do you understand what am I saying?

错误是说您处于文件系统的受保护部分。这意味着您可能希望将文件保存在未受保护的部分中。因此,您可能希望将“foo.txt”部分替换为“/mnt/sdcard/foo.txt”或“/storage/sdcard0/foo.txt”或手机上内部存储的路径。你明白我在说什么吗?

#2


Qpython has disabled writing to files, my recommendation is to find a different script interpreter like the inpython app on android, or the python module in Termux and run it from there.

Qpython禁止写入文件,我的建议是找到一个不同的脚本解释器,如android上的inpython应用程序,或者Termux中的python模块,然后从那里运行它。

#1


The error is saying that you are in a protected part of a file system. That means you may want to save the file in an un-protected part. So, you may want to replace the "foo.txt" part with "/mnt/sdcard/foo.txt" or "/storage/sdcard0/foo.txt" or whatever is the path of internal storage on your phone. Do you understand what am I saying?

错误是说您处于文件系统的受保护部分。这意味着您可能希望将文件保存在未受保护的部分中。因此,您可能希望将“foo.txt”部分替换为“/mnt/sdcard/foo.txt”或“/storage/sdcard0/foo.txt”或手机上内部存储的路径。你明白我在说什么吗?

#2


Qpython has disabled writing to files, my recommendation is to find a different script interpreter like the inpython app on android, or the python module in Termux and run it from there.

Qpython禁止写入文件,我的建议是找到一个不同的脚本解释器,如android上的inpython应用程序,或者Termux中的python模块,然后从那里运行它。