python 指定位数随机字符串

import os; 
print(os.urandom(16))

随机数字方法:1000-5000 之间的随机数
import random
random.randint(1000,5000)