Python指定生成N位随机数
import random def randomNum(N): random_number = random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',N) return ''.join(random_number) print(randomNum(16)) print(randomNum(32))
import random def randomNum(N): random_number = random.sample('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',N) return ''.join(random_number) print(randomNum(16)) print(randomNum(32))