python中random模块

 

>>> import random
>>> random.randint(1,10)   ## 随机抽取1-10的数字
1
>>> random.randint(1,10)
4
>>> random.randint(1,10)
9
>>> random.randint(1,100)
67
>>> random.randint(1,100)
42
>>> random.randint(1,100)
6
>>> a = ["aa","bb","cc","dd","ee","ff"]
>>> random.choice(a)   ## 随机抽奖
'bb'
>>> random.choice(a)
'ee'
>>> random.choice(a)
'cc'
>>> random.choice(a)
'bb'
>>> random.choice(a)
'bb'
>>> random.choice(a)
'bb'

 

上一篇:Shell运算符(2)- 数值运算方法


下一篇:hive导数据