I was wondering if anyone knows of a good way to generate GUIDs on python google ap开发者_运维技巧p engine. I feel like there is a simple way that people are using, what would you suggest.
The uuid module should be available.
Why do you need uuids? Usually they're necessary to make really unique primary keys, but GAE's datastore essentially ought to be taking care of that for you.
Code example using the uuid module:
from uuid import uuid4
print(uuid4())
# Output: 7d720c5a-b3e9-455e-961c-0e37b330b098
import uuid
print(uuid.uuid4().hex)
Assuming the module is available in Google App Engine, check out Python's uuid module.
Any chance they are guid's for things you're storing in the datastore?
If so, I believe object.key is a GUID
精彩评论