Python uuid4, How to limit the length of Unique chars

In Python, I am using uuid4() method to create a unique char set. But I can not find a way to limit that to 10 or 8 characters. Is there any way?

uuid4()

ffc69c1b-9d87-4c19-8dac-c09ca857e3fc

Thanks.


Try :

x = uuid4()
str(x)[:8]

Output :

"ffc69c1b"

Is there a way to substring a string in Python?

链接地址: http://www.djcxy.com/p/55130.html

上一篇: 调用函数而不先创建类的实例

下一篇: Python uuid4,如何限制Unique字符的长度