python 随机数
来源:互联网 发布:淘宝牙齿美白仪有用吗 编辑:程序博客网 时间:2024/04/28 08:38
#!/usr/bin/python2.6
# -*- coding: utf-8 -*-
import random
import string
print "=======12 <= n <= 20"
print random.randint(12, 20)
print "=======12 <= float <= 20"
print random.uniform(10, 20)
#2代表是2的倍数,也就一定就偶数
print random.randrange(0, 101, 2)
#从预设的字符中随机选择一个
print random.choice('&#%^*')
#从预设的字符中随机选择2个
print random.sample('&#%^*',2)
#选择3个字符后将其连接
print string.join(random.sample(['a','b','c','d','e','f','g','h','i','j'], 3)).replace(" ","")
#选择某一个字符串
print random.choice ( ['apple', 'pear', 'peach', 'orange', 'lemon'] )
#洗牌
items = [1, 2, 3, 4, 5, 6]
random.shuffle(items)
print items
# -*- coding: utf-8 -*-
import random
import string
print "=======12 <= n <= 20"
print random.randint(12, 20)
print "=======12 <= float <= 20"
print random.uniform(10, 20)
#2代表是2的倍数,也就一定就偶数
print random.randrange(0, 101, 2)
#从预设的字符中随机选择一个
print random.choice('&#%^*')
#从预设的字符中随机选择2个
print random.sample('&#%^*',2)
#选择3个字符后将其连接
print string.join(random.sample(['a','b','c','d','e','f','g','h','i','j'], 3)).replace(" ","")
#选择某一个字符串
print random.choice ( ['apple', 'pear', 'peach', 'orange', 'lemon'] )
#洗牌
items = [1, 2, 3, 4, 5, 6]
random.shuffle(items)
print items
0 0
- python 随机数
- python 随机数
- python 随机数
- python 随机数
- python 随机数
- python 随机数
- python-- 随机数
- python 随机数
- python 随机数
- python 随机数
- python 随机数
- python : 随机数
- python随机数
- Python随机数
- python随机数
- python 随机数
- Python 随机数
- Python随机数
- Python thread pool similar to the multiprocessing Pool?
- Objective-C不能用@try
- Android Volley完全解析
- selector的使用
- Android 常用设计模式
- python 随机数
- 类的对象构造顺序以及可能会引发的问题的深入分析
- Linux中断完全分析
- JSOUP获取网页数据返回403错误(403 error loading URL,connection类)
- XTU 1238 Segment Tree (线段树)
- 天津市心理咨询机构
- C++11 lambda 表达式
- Android Recovery OTA升级(二)—— Recovery源码解析
- ajaxFileUpload 上传文件