如果以上回答沒有爲你工作在字符串格式轉換的有效UUID回到實際UUID對象...使用uuid.UUID(your_uuid_string)
爲我工作。
In [6]: import uuid
...:
...: o = {
...: "name": "Unknown",
...: "parent": "Uncategorized",
...: "uuid": "06335e84-2872-4914-8c5d-3ed07d2a2f16"
...: }
...:
...: print uuid.UUID(o['uuid']).hex
...: print type(uuid.UUID(o['uuid']).hex)
06335e84287249148c5d3ed07d2a2f16
<type 'str'>
In [7]: your_uuid_string = uuid.UUID(o['uuid']).hex
In [8]: print uuid.UUID(your_uuid_string)
06335e84-2872-4914-8c5d-3ed07d2a2f16
In [9]: print type(uuid.UUID(your_uuid_string))
<class 'uuid.UUID'>
你可能想看看[本等提問/回答(http://stackoverflow.com/questions/534839/how-to-create-a-guid-in-python?rq=1)還有[這裏的文檔](http://docs.python.org/2/library/uuid.html)。 :) – summea 2013-04-07 05:23:51