Python指定生成N位随机数

import random

def randomNum(N):
    random_number = random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',N)
    return  ''.join(random_number)

print(randomNum(16))
print(randomNum(32))

  

posted @ 2021-08-30 16:07  lucky_tomato  阅读(1190)  评论(0编辑  收藏  举报