2019-03-17
阅读量:
461
python如何生成4位数字OTP?
python如何生成4位数字OTP
代码:
# import library
import math, random
# function to generate OTP
def generateOTP() :
# Declare a digits variable
# which stores all digits
digits = "0123456789"
OTP = ""
# length of password can be chaged
# by changing value in range
for i in range(4) :
OTP += digits[math.floor(random.random() * 10)]
return OTP
# Driver code
if __name__ == "__main__" :
print("OTP of 4 digits:", generateOTP())
输出:
OTP of 4 digits: 3211






评论(0)


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