import random
test1 = (1,2,3,4,5,6,7,8,9,0,)
test2 = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',)
num1 = random.sample(test1,2)
nump1 = random.sample(test2,2)
test_out = random.sample(num1 + nump1,4)
test_print = str(test_out[0]) + str(test_out[1]) + str(test_out[2]) + str(test_out[3])
print(test_print)
if __name__ == '__import_':
main()
此文比较适合初学者,在对python有更深层次的了解后,可以知道还有更简便的写法,
python语言精华就是精练,大家有好的方法可以互相交流一下
进群:516107834 即可获取数十套PDF哦!
网友评论