
Python模块
a_small_python
能力一般,水平有限,如有错误,欢迎指正~~~
展开
-
模块03----Math (部分常用)
返回≧ x 的最小整數 math.ceil(x) >>> math.floor(3.4) 結果 4返回 ≦ x 的最大整数 math.floor(x) >>> math.floor(3.4) 結果 3返回与 y 同号的 x 值 math.copysign(x,y)返回e**x math.exp(x)返回 x 的绝对值 math.fabs...原创 2018-02-10 22:34:34 · 144 阅读 · 0 评论 -
模块01----Collections
collections的常用类型有:计数器(Counter)双向队列(deque)默认字典(defaultdict)有序字典(OrderedDict)可命名元组(namedtuple)使用以上类型时需要导入模块 from collections import *1. CounterCounter 作为字典(dict)的一个子类用来进行hashtable计数,将元素进行数量统计、计数后返回一个字典,...原创 2018-02-10 22:29:48 · 139 阅读 · 0 评论 -
模块04----OS
os模块常用的文件处理函数函数 使用说明access(path, mode) 按照mode指定的权限访问文件open(path, flags, mode=0o777, *, dir_fd=None) 按照mode指定的权限打开文件,默认权限为可读、可写、可执行chmod(path, mode, *, dir_fd=None, follow_symlinks=True) 改变文件的访问权限remov...原创 2018-02-10 22:35:06 · 144 阅读 · 0 评论 -
模块05----随机数 (部分常用)
import random1. random.randint(a,b)返回一个随机整数N,其中a <= N <= b (ab必须为整数)2.random.randrang([start],stop[,step])返回某个区间内的整数,可以设置step,只能传入整数例如random.randrang(10,100,2)结果相当于从[10,12,14,...,98]序列中获取一个随...原创 2018-02-10 22:36:02 · 203 阅读 · 0 评论 -
模块02----Pickle
文件的存储pickle模块 能把所有对象转换为二进制存放存放:pickling读取:unpickling存储 dump方法import picklea = [5465,'asdasda','q7qs5']file1 = open('data.data','wb')pickle.dump(a,file1)file1.close()读取 load方法file2 = open('data.data'...原创 2018-02-10 22:30:44 · 192 阅读 · 0 评论