python的内置模块
2019-01-08 20:50
141 查看
1.随机小数
random()产生大于且小于1的小数 import random ret=random.random() print(ret)
2.uniform(a,b)产生指定范围内的随机小数
import random ret=random.uniform(1,2) print(ret)
3.randint(a,b)产生a,b范围内的整数,包含开头和结尾
import random ret=random.randint(2,6) print(ret)
4.randrange(start,stop,[step])产生范围内的整数,包含开头不包含结尾。
step 指定产生随机数的步长。
import random ret=random.randrange(1,16,2) print(ret)
5.random.choice(lst) 随机返回序列中的一个数据
import random lst=[1,2,3,4,5,6] ret=random.choices(lst) print(ret)
6.shuffle 打乱列表顺序
import random lst=[1,2,3,4,5,6] random.shuffle(lst) print(lst)
7.sys模块
import sys print(inport sys) 返回解释器的版本号 print(sys,path) 返回模块搜索路径 接受控制台输入的参数,参数以列表的形式保存 第一个参数接受的是参数的名称
相关文章推荐
- python入门----3+1个内置模块:sys,os, time,datetime
- Python内置性能分析模块timeit
- Python 内置模块1
- 6.python模块(导入,内置,自定义,开源)
- 转 python内置正则表达式(re)模块官方文档简要中文版
- Python3.5——内置模块详解之time与datetime模块
- Python_Day_5装饰器、字符串格式化、序列化、内置模块、生成器、迭代器之篇
- python内置模块(loggin、os)
- Python内置ssl模块编程(1)
- Python爬虫——6.Tesseract机器视觉(配合python内置的PIL即pillow模块)
- python 的内置模块 re
- python内置模块~shutil
- Python内置的urllib模块不支持https协议的解决办法
- Python 内置 time 模块 API 中文档案
- python常用内置模块,执行系统命令的模块
- Python的内置模块math介绍
- python的内置模块
- Python学习笔记(三十八)— 内置模块(7)contextlib
- Python常用内置模块之xml模块(详解)
- python基础:模块的搜索路径、pyc临时文件、内置属性