自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(46)
  • 资源 (1)
  • 收藏
  • 关注

原创 grep命令

grep pattern file1 file2 搜索匹配内容grep pattern file1 -o只显示匹配内容grep pattern file1 --color=auto增加颜色grep -E “pattern” file1 正则表达式匹配grep -c pattern file1统计匹配到的行数grep -n pattern file1输出匹配到的行数grep...

2020-08-22 09:58:46 352

原创 xargs命令

1. 介绍xargs主要用于将标准输出转化为命令行参数, 传递给其他命令执行, 因为有些命令并不支持管道命令接收标准输入;2. 使用基本使用:echo "one two three" | xargs mkdir单独使用:运行xargs 相当于运行: xargs echo打印执行的命令:echo 'one two three' | xargs -p touch # 打印命令, 确认后执行echo 'one two three' | xargs -t touch # 打印命

2020-08-22 09:57:50 297

原创 sed命令

1. 格式sed 选项 sed命令 输入文件sed -f script_file 输入文件 (从文件读取sed命令)2. 选项选项说明-n静默输出, 不打印内容-e可通过-e指定要执行的多个命令-f要执行的命令文件

2020-08-22 09:57:18 1240

原创 awk命令

1. 格式awk 选项 ‘匹配规则{执行命令}’ file_name例如: awk -F: '/^$/{print “blank lines”} test.txt选项含义-F fs指定分隔符-f file指定执行的脚本文件-v var=val在执行处理过程之前,设置一个变量 var,并给其设备初始值为 val。数据变量:$0: 整行$n: 第n个数据字段BEGIN和END关键字: 分别在读取文件前和读取文件后执行;$ awk 'BEGIN{pr

2020-08-22 09:56:22 417

原创 python内置函数

1.enumerate()Return an enumerate object.The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument.enumerate is useful f...

2019-12-15 09:26:38 260

原创 python关于os模块

1.介绍:os模块用于python文件和操作系统的交互2.os模块函数(1)os.path.abspath(path)Return a normalized absolutized version of the pathname path. On most platforms, this is equivalent to calling the function normpath() ...

2019-12-15 09:24:53 169

原创 python关于re模块(正则表达式)

1.元字符(1) \b:Matches the empty string, but only at the beginning or end of a word. A word is defined as a sequence of word characters. Note that formally, \b is defined as the boundary between a \w...

2019-12-15 09:24:02 235

原创 python关于uwsgi

一、定义1.uWSGI定义uWSGI是一个web服务器,实现了WSGI协议,uwsgi协议,http协议等。uWSGI的主要特点是:超快的性能(c语言编写)低内存占用多app管理详尽的日志功能(可以用来分析app的性能和瓶颈)高度可定制(内存大小限制,服务一定次数后重启等2.uwsgi协议uwsgi:与WSGI一样是一种通信协议,是uWSGI服务器的独占协议,用于定义传输信息的...

2019-12-15 09:22:32 5368

原创 python关于装饰器

#1.练习import timedef fucker0(m): print(m) def fucker(fuc): def fucker2(*args, **kwargs): st_time=time.time() s=fuc(*args, **kwargs)#注意参数传递 ed_ti...

2019-04-25 14:40:08 173

原创 python关于静态属性, 类方法, 静态方法

1.静态属性property在类的函数属性前加@property可以让该函数以数据属性的方式调用.注意:1. 静态属性不可传参数,(只有self)2.类的实例默认无法修改静态属性3.如果想对实例修改,调用静态属性做限制,可以用setter, getter, deleter,等装饰器.示例1:property使用class Test: def __init__(self, a, ...

2019-04-25 14:39:21 2048

原创 python关于metaclass元类

By default, classes are constructed using type(). The class body is executed in a new namespace and the class name is bound locally to the result of type(name, bases, namespace).The class creation p...

2019-04-25 14:38:56 246

原创 python关于namespace和scope(命名空间和作用域)

1.namespace(1)定义A namespace is a mapping from names to objects. Most namespaces are currently implemented as Python dictionaries, but that’s normally not noticeable in any way (except for performan...

2019-04-25 14:38:29 856

原创 python关于socket模块

1.socket概述Of the various forms of IPC, sockets are by far the most popular. On any given platform, there are likely to be other forms of IPC that are faster, but for cross-platform communication, so...

2019-04-25 14:38:02 697

原创 python关于configparser模块

1.介绍该模块主要用来操作及设置配置文件, 可以以键值对的形式存放信息.例如:[DEFAULT]ServerAliveInterval = 45Compression = yesCompressionLevel = 9ForwardX11 = yes [bitbucket.org]User = hg [topsecret.server.com]Port = 50022...

2019-04-25 14:37:16 196

原创 python关于subprocess模块

1.介绍通过subprocess模块可以在python程序中开设一个子进程, 该子进程在shell中执行相关命令然后主进程可获取其运行结果2.Popen对象通过Popen可开启子进程, Popen为非阻塞的:class subprocess.Popen(args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=N...

2019-03-27 12:23:51 344

原创 python关于logging模块

1.内置模块logging主要用于自动方便的生成日志;默认的日志级别设置为WARNING(日志级别等级CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET),默认的日志格式为日志级别:Logger名称:用户输出消息。2.基本使用import logginglogging.basicConfig( leve...

2019-03-27 10:30:49 185

原创 Nginx的Permission denied错误

原因:通过ps命令查看nginx进程为用户nginx,而uwsgi进程为用户root。估计是权限不一致导致nginx无法访问uwsgi进程(socket方式通信)。所以修改nginx的配置文件/etc/nginx/nginx.conf,把user选项从nginx改成root。之后执行重启命令systemctl restart nginx如果还不行,那就是selinux,执行下面命令:s...

2019-03-19 21:22:53 728

原创 Scrapy自定义proxy代理及https证书

1.代理方式一:使用默认os.environ{http_proxy:http://root:woshiniba@192.168.11.11:9999/https_proxy:http://192.168.11.11:9999/}方式二:使用自定义下载中间件 def to_bytes(text, encoding=None, errors='strict'): ...

2019-03-10 21:43:53 2703

原创 django关于ModelForm

1.class ModelFormIf you’re building a database-driven app, chances are you’ll have forms that map closely to Django models. For instance, you might have a BlogComment model, and you want to create a...

2019-01-31 12:10:22 830

原创 django关于文件上传

1.简单示例:from django import formsclass UploadFileForm(forms.Form):title = forms.CharField(max_length=50)file = forms.FileField()A view handling this form will receive the file data in request.FIL...

2018-12-22 12:03:07 1201

原创 django关于form组件

利用form组件可以很方便的实现对网页表单数据的管理及响应;1.Form Fields(1)BooleanFieldclass BooleanField(**kwargs)• Default widget: CheckboxInput• Empty value: False• Normalizes to: A Python True or False value.• Validat...

2018-12-20 21:25:58 588

原创 django关于modles

1.ORM对象-关系映射(OBJECT/RELATIONALMAPPING,简称ORM),是随着面向对象的软件开发方法发展而产生的。用来把对象模型表示的对象映射到基于S Q L 的关系模型数据库结构中去。这样,我们在具体的操作实体对象的时候,就不需要再去和复杂的 SQ L 语句打交道,只需简单的操作实体对象的属性和方法 。O R M 技术是在对象和关系之间提供了一条桥梁,前台的对象型数据和数据...

2018-12-09 23:26:12 1295

原创 Django关于标签(tag)

1.if使用语法如下:{% if name == 'yuan' and hobby|length < 5 %} hello yuan{% elif name == 'fuck' %} hello shit{% else %} no user{% endif %}注意:1). if中不允许使用括号,如果想表示优先级,使用if嵌套;...

2018-12-04 23:22:10 1352

原创 Django关于内置过滤器filter

1.add将变量与参数相加This filter will first try to coerce both values to integers. If this fails, it’ll attempt to add the values together anyway. This will work on some data types (strings, list, etc.) and ...

2018-12-04 19:03:04 895

原创 html简介

1.定义HTML:hyper text markup language即超文本标记语言;超级文本标记语言是标准通用标记语言下的一个应用,也是一种规范,一种标准 ,它通过标记符号来标记要显示的网页中的各个部分.2.结构超文本即指页面内包含图片, 音乐, 链接等非文字元素.html文档为树形结构, 它包括一个根标签< html>, 下面有head标签部分和body标签部分,head...

2018-11-19 22:13:43 347

原创 python关于IO模型

1.事件驱动编程(1)定义:传统的计算机程序执行都是线性的, 也即程序的执行顺序,行为都是可预测的, 而事件驱动的程序的运行与外部事件有关, 外部输入什么操作,程序就执行相应的函数,完全由事件驱动,事前不可预测;(2)执行流程:事件驱动程序的一个基本结构是一个事件收集器, 一个事件发送器, 一个事件处理器;1.有一个事件队列, 其中每个事件对应一个动作;2.用户发生一个操作, 就往事件队列...

2018-11-19 09:03:07 310 1

原创 python关于select, selectors模块

1.select模块1.1概述This module provides access to the select() and poll() functions available in most operating systems, devpoll() available on Solaris and derivatives, epoll() available on Linux 2.5+ ...

2018-11-19 09:02:16 4740 1

原创 python关于协程coroutine

1.定义协程, 又名微线程, coroutine协程的特点在于执行子程序的过程中可以中断, 挂起去执行另一个子程序;看起来执行过程有点像多线程, 但不同的是协程是一个线程内部进行切换;多个线程相对独立, 有自己的上下文, 切换受系统控制; 而协程也相对独立, 有自己的上下文, 但切换由协程自己控制;优点:1.由于协程是单线程执行, 切换只在程序内部, 没有系统级别的消耗, 相比线程和进程性能...

2018-11-16 14:58:47 362

原创 python关于multiprocessing(多进程)模块

1.概述multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side...

2018-11-15 22:02:52 4786 1

原创 python关于queue模块

2018-11-14 14:38:40 1912

原创 python关于threading模块

1.简介This module constructs higher-level threading interfaces on top of the lower level _thread module. See also the queue module此模块在底层的_thread模块之上构建了更高层的线程接口2.threading模块下的方法(1) threading.active...

2018-11-13 14:30:45 492

原创 python关于类的内置attr方法

1.__ getattr__(self, item)当类的实例调用的属性或方法不存在时自动执行__getattr并报错; 在类中可以对其进行自定义修改,用此方法可实现不同类之间的授权操作.2.__ setattr__(self, key, value)当类的实例进行修改或添加属性时实质上就是执行__setattr方法;可在类中对其进行自定义修改,可导致其不能成功修改属性.3.__ dela...

2018-11-02 22:17:17 1483

原创 python关于__ enter__和__exit__方法,with语句

1.上下文管理协议A context manager is an object that defines the runtime context to be established when executing a with statement. The context manager handles the entry into, and the exit from, the desired...

2018-11-01 17:20:35 2628

原创 python关于描述符__set__ ,__get__ , __delete__

1.描述符The following methods only apply when an instance of the class containing the method (a so-called descriptor class) appears in an owner class (the descriptor must be in either the owner’s class...

2018-10-31 22:33:28 2888

原创 python利用定义类实现迭代器协议

1.具有__ next__和__ iter__方法的对象即被视为迭代器,其中next方法每执行一次返回迭代的下一项,而iter方法可以把对象变成迭代器.执行for循环的本质即是先对对象使用iter方法, 然后不断使用next方法,直到报出StopIteration. 故可直接在类中定义这两个方法,从而实现迭代器协议.下例:class Test: def __init__(self):...

2018-10-31 19:56:47 363

原创 python关于类的call方法

1.__ call__object.call(self[, args…])Called when the instance is “called” as a function; if this method is defined, x(arg1, arg2, …) is a shorthand for x.call(arg1, arg2, …).当对象像函数一样被调用时,就想当于执行它的...

2018-10-31 19:33:53 6675 2

原创 python关于类的slots属性

1.__ slots__属性__ slots__ allow us to explicitly declare data members (like properties) and deny the creation of __ dict__ and __ weakref__ (unless explicitly declared in __ slots__ or available in a...

2018-10-31 19:28:12 1011

原创 python关于对象的字符串显示str和repr以及

1.reprobject.__ repr__(self)Called by the repr() built-in function to compute the “official” string representation of an object. If at all possible, this should look like a valid Python expression ...

2018-10-30 22:17:29 512

原创 python关于字符串内置方法

1. str.split()Return a list of the words in the string, using sep as the delimiter string.sepThe delimiter according which to split the string.None (the default value) means split according to an...

2018-10-26 22:09:30 728

原创 python关于函数形参

1.函数的默认参数是可变数据类型时,要尤其注意:如果函数执行过程中默认参数被修改,则永久被修改(下次调用时还会使用上一次被改过的默认参数)Default parameter values are evaluated from left to right when the function definition is executed. This means that the expressio...

2018-10-25 23:02:25 456

迭代器图解

迭代器图解..

2018-10-19

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除