[ Python - 5 ] 通过random模块生成随机字符串
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ Python - 5 ] 通过random模块生成随机字符串相关的知识,希望对你有一定的参考价值。

import random checkcode = ‘‘ for i in range(4): if i == random.randint(0,3): current = chr(random.randrange(65,90)) checkcode += str(current) else: checkcode += str(i) print(checkcode)
以上是关于[ Python - 5 ] 通过random模块生成随机字符串的主要内容,如果未能解决你的问题,请参考以下文章