先上代码:

import random
gen_fingerprint = lambda n=16,s=2: ":".join([ "".join(random.sample("0123456789abcdef",s)) for i in range(0, n) ])

n=16, s=2,默认指纹格式,返回结果类似:

47:6f:09:2f:bd:e7:d3:04:1c:7a:40:16:08🆎9f:8a

n=6,s=2,返回类似mac地址格式:

fe:d7:d9:52:24:fa

n: 长度

s: 每段字符数

比如n=7, s=4,返回类似于:

4e98:a653:7cf2:520e:9d7f:619c:9bc3

·End·