2019-03-17
阅读量:
400
如何在python生成长度为6的字母数字OTP
如何在python生成长度为6的字母数字OTP
代码
play_arrow
brightness_4# import library
import
math, random
# function to generate OTP
def
generateOTP() :
# Declare a string variable
# which stores all string
string =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
OTP =
""
length =
len(string)
for
i in
range(6) :
OTP +=
string[math.floor(random.random() *
length)]
return
OTP
# Driver code
if
__name__ ==
"__main__"
:
print("OTP of length 6:", generateOTP())
输出:
OTP of length 6: pyelJl






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论