
model of python
syqnyue
这个作者很懒,什么都没留下…
展开
-
python标准库:queque
queue模块实现了多生产者,多消费者队列。在多线程环境下,该队列能实现多个线程间安全的信息交换。queue模块介绍模块实现了3种类型的队列,区别在于队列中条目检索的顺序不同。在FIFO队列中,按照先进先出的顺序检索条目。在LIFO队列中,最后添加的条目最先检索到(操作类似一个栈)。在优先级队列中,条目被保存为有序的(使用heapq模块)并且最小值的条目被最先检索。queue模块的类和异常...原创 2019-04-24 12:24:14 · 865 阅读 · 0 评论 -
python标准库:threading
线程是CPU分配资源的基本单位。但一个程序开始运行,这个程序就变成了一个进程,而一个进程相当于一个或者多个线程。当没有多线程编程时,一个进程也是一个主线程,但有多线程编程时,一个进程包含多个线程,包括主线程。使用线程可以实现程序的并发。创建线程用 threading.Thread 直接在线程中运行函数import timeimport threadingdef thread_run...原创 2019-04-24 12:24:06 · 3428 阅读 · 2 评论 -
python标准库: argparse模块
1、定义:argparse是python标准库里面用来处理命令行参数的库2、命令行参数分为位置参数和选项参数:位置参数就是程序根据该参数出现的位置来确定的如:[root@openstack_1 /]# ls root/ #其中root/是位置参数选项参数是应用程序已经提前定义好的参数,不是随意指定的如:[root@openstack_1 /]# ls -l # -l 就是ls...转载 2019-04-24 12:23:35 · 451 阅读 · 0 评论 -
python标准模块:random
Functions for integersrandom.randrange(stop)random.randrange(start, stop[, step])相当于random.choice(range(start, stop, step))Functions for sequencesrandom.choice(seq)random.choices(population, wei...原创 2019-02-26 10:39:52 · 173 阅读 · 0 评论 -
Python3.7的标准模块operator备胎模块
OperationSyntaxFunctionAdditiona + badd(a, b)Concatenationseq1 + seq2concat(seq1, seq2)Containment Testobj in seqcontains(seq, obj)Divisiona / bdiv(a, b) (without future.di...原创 2019-02-18 19:17:22 · 260 阅读 · 0 评论 -
python标准库:collections
collections.dequedeque是双端队列(double-ended queue)的缩写,由于两端都能编辑,deque既可以用来实现栈(stack)也可以用来实现队列(queue)。1.创建deque序列:from collections import dequed=deque()2.append(往右边添加一个元素)appendleft(往左边添加一个元素)d=deq...原创 2019-02-17 13:53:10 · 494 阅读 · 0 评论 -
下载并解压文件
从命令行下载文件首先打开cmd命令行模式, Windows键+r,然后在里面输入cmd,按回车即可。这时候你就看见命令行模式了在命令行中输入 start powershell就可启动powershell了,如第二幅图所示就是powershell了在powershell中我们输入一下命令$client = new-object System.Net.WebClient$cl...原创 2019-04-24 12:22:15 · 934 阅读 · 0 评论 -
python标准库:scipy.misc
scipy.misc.imresizeThis function uses bytescale under the hood to rescale images to use the full (0, 255) range if mode is one of None, ‘L’, ‘P’, ‘l’.原创 2019-04-24 12:25:52 · 2599 阅读 · 0 评论 -
python标准库:路径与文件(os.path&glob)
os.path包os.path包主要是处理路径字符串,比如说’/home/vamei/doc/file.txt’,提取出有用信息。import os.pathpath = '/home/vamei/doc/file.txt'print(os.path.basename(path)) # 'file.txt' (查询路径中包含的文件名) print(os.path.dirname(...原创 2019-04-24 12:23:52 · 944 阅读 · 0 评论