Home > Article > Backend Development > Use python to randomly generate 6-digit password example code
This article explains in detail how to use python to randomly generate a 6-digit password example code
#!/usr/bin/env python # -*- coding: UTF-8 -*- import random #生成随机6位随机数含字母 code = [] for i in range(6): if i == random.randint(1,5): code.append(str(random.randint(1,5))) else: code.append(chr(random.randint(65,90))) print ''.join(code) #转换成字符串
The above is the detailed content of Use python to randomly generate 6-digit password example code. For more information, please follow other related articles on the PHP Chinese website!