随机形成字母和数字组成的五位字符码。 [[email protected] python]# vim timee.py import random def coder(): code = ‘‘ for i in range(5): add = random.choice([random.randrange(10),chr(random.randrange(65,91))]) #数字和字母 code += str(add) print (code) coder() 运行结果: [[email protected] python]# python timee.py NYO6F [[email protected] python]# python timee.py MS15V [[email protected] python]# python timee.py 16SR6 [[email protected] python]# python timee.py 9Z3SW [[email protected] python]# python timee.py XN0KW [[email protected] python]# python timee.py 1PPT9 [[email protected] python]# python timee.py E25U2