问题
I have seen a number of questions relating to writing files & creating new directories using Python and GAE, but a number of them conclude (not only on SO) by saying that Python cannot write files or create new directories. Yet these commands exist and plenty of other people seem to be writing files and opening directories no problem.
I'm trying to write to .txt files and create folders and getting the following errors:
Case #1:
with open("aardvark.txt", "a") as myfile:
myfile.write("i can't believe its not butter")
produces "IOError: [Errno 30] Read-only file system: 'aardvark.txt'". But i've checked and it's def-o not a read only file.
Case #2:
folder = r'C:\project\folder\' + str(name)
os.makedirs(folder)
produces "OSError: [Errno 38] Function not implemented: 'C:\project\folder'"
What am i missing?
回答1:
Appengine does not support any write operations to the filesystem (amongst other restrictions). The BlobStore does have a file like api, but you cannot rewrite/append to existing blob store entities. The dev server also presents these restrictions to emulate production environment.
You should probably have a read of the some of the docs about appengine. The overview doc https://developers.google.com/appengine/docs/python/overview explicitly states you can't write.
回答2:
AppEngine can now write to a local "ephemeral" disk storage when using Managed-VM which is not supported when using the sandbox method as specified on this documentation:
https://cloud.google.com/appengine/docs/managed-vms/tutorial/step3
来源:https://stackoverflow.com/questions/15699836/makedirs-error-can-gae-python-create-new-directories-folders-or-not