getUuid() { var s = []; var a = "0123456789abcdef"; for (var i = 0; i < 32; i++) { s[i] = a.substr(Math.floor(Math.random() * 0x10), 1) } s[14] = "4"; s[19] = a.substr((s[19] & 0x3) | 0x8, 1); s[8] = s[13] = s[18] = s[23]; var b = s.join(""); return b } 转换成python语言
时间: 2024-04-28 22:26:21 浏览: 164
小程序中使用uuid
5星 · 资源好评率100%
import random
def get_uuid():
s = []
a = "0123456789abcdef"
for i in range(32):
s.append(a[random.randint(0, 15)])
s[14] = "4"
s[19] = a[(int(s[19], 16) & 0x3) | 0x8]
s[8] = s[13] = s[18] = s[23]
return ''.join(s)
阅读全文