开发者

Good way to generate GUIDs on app engine?

开发者 https://www.devze.com 2023-02-05 20:58 出处:网络
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 mod

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

0

精彩评论

暂无评论...
验证码 换一张
取 消