标签:_id port clock 使用 blog date pytho UI creat
import uuid def create_uid(): return str(uuid.uuid1()) if __name__ == ‘__main__‘: print(type(create_uid())) print(create_uid()) print(create_uid()) print(create_uid()) --- <class ‘str‘> cdcb9030-51e8-11e7-881d-3c52824c8d6f cdcb9031-51e8-11e7-86b4-3c52824c8d6f cdcb9032-51e8-11e7-be6c-3c52824c8d6f
- 示例1:
import time,hashlib def create_id(): m = hashlib.md5(str(time.clock()).encode(‘utf-8‘)) return m.hexdigest() if __name__ == ‘__main__‘: print(type(create_id())) print(create_id()) print(create_id()) print(create_id()) --- <class ‘str‘> b96d5fca757c00cbd53ae672f60e7ffe 3e8391327caa4850077768d88ee18c7e df28a1e9895052608c2a6897f13d5659
- 示例2:
import time,hashlib def create_id(): m = hashlib.md5() m.update(bytes(str(time.clock()),encoding=‘utf-8‘)) return m.hexdigest() if __name__ == ‘__main__‘: print(type(create_id())) print(create_id()) print(create_id()) print(create_id()) --- <class ‘str‘> be4a24bec22f46c84a4dde78e68cb838 53e8e0c48c885b91fb2565cbe87b8423 f8fd24c3b8ce1a39217134e22203a5c4
标签:_id port clock 使用 blog date pytho UI creat
原文地址:http://www.cnblogs.com/standby/p/7021943.html