随机验证码
主要chr()内置函数,与之相关的函数是ord()
import random li = list() for i in range(4): ret = random.randrange(65,91) j = random.randrange(1,5) if j == 3 or j == 5: ret = random.randrange(0,10) else: ret = chr(ret) li.append(str(ret)) code = ''.join(li) print(code)