
python学习
Vincent_xx_
这个作者很懒,什么都没留下…
展开
-
lambda函数用法
lambda只是一个表达式,函数体比def简单很多。lambda的主体是一个表达式,而不是一个代码块。仅仅能在lambda表达式中封装有限的逻辑进去。lambda表达式是起到一个函数速写的作用。允许在代码内嵌入一个函数的定义。lambda用法:lambda formal param: expression返回值为expression如下例转载 2018-01-11 23:27:31 · 734 阅读 · 0 评论 -
Matplotlib.pyplot 用法2
"""@author: Vincnet_Sheng@file: Matplotlib-2.py@time: 2018/1/6 0006 下午 2:57#-*- coding: utf-8 -*"""# Target:1) xlim,ylim 设置图像上xy轴显示的范围# 2)xticks, yticks改变坐标轴的刻度显示(可转为显示字符string)import原创 2018-01-07 00:20:22 · 284 阅读 · 0 评论 -
Matplotlib.pyplot 用法 3
"""@author: Vincnet_Sheng@file: Matplotlib-3.py@time: 2018/1/6 0006 下午 4:41#-*- coding: utf-8 -*"""# from official documentary# https://matplotlib.org/tutorials/introductory/pyplot.html#sphx-gl原创 2018-01-07 00:33:34 · 279 阅读 · 0 评论 -
Matplotlib.pyplot 用法 4
@author: Vincnet_Sheng@file: Matplotlib-4.py@time: 2018/1/6 0006 下午 5:19#-*- coding: utf-8 -*"""# https://matplotlib.org/gallery/subplots_axes_and_figures/subplot.html# Target: 1) 描述数据点形状(三角形,大原创 2018-01-07 00:35:16 · 296 阅读 · 0 评论 -
Matplotlib.pyplot 用法 5
"""@author: Vincnet_Sheng@file: Matplotlib-5.py@time: 2018/1/6 0006 下午 7:10#-*- coding: utf-8 -*"""# Target: 在figure上呈现text标注,# method 1: annotate,# method 2: text()函数im原创 2018-01-07 00:39:23 · 255 阅读 · 0 评论 -
Python 里 immutable和hashable的概念
原文:http://www.lfhacks.com/tech/immutable-hashable-in-pythonPython 里有两个紧密联系的概念: immutable和hashable. 都是描述一个对象的属性。immutableimmutable指对象一经创建,即不可修改。对象是不是immutable取决于数据类型,比如整型(integer)、字符串转载 2018-01-16 22:11:41 · 799 阅读 · 0 评论 -
Python 字典类函数:items(返回列表),iteritems(返回迭代器)
字典items()方法和iteritems()方法,是python字典的内建函数,分别会返回Python列表和迭代器,下面一起来看下字典items()和iteritems()的具体操作方法。作用python字典的items方法作用:是可以将字典中的所有项,以列表方式返回。如果对字典项的概念不理解,可以查看Python映射类型字典基础知识一文。因为字典是无序的,所以用items方法返转载 2018-01-08 10:29:19 · 5054 阅读 · 0 评论 -
简易函数:lambda和operator.itemgetter用法
1. operator.itemgetter ( )operator模块提供的itemgetter定义了一个函数。input:索引序号, output:函数哪些维的数据下面看例子。a = [1,2,3] >>> b=operator.itemgetter(1) //定义函数b,获取对象的第1个域的值>>> b(a) 2 >>> b=opera转载 2018-01-08 14:09:47 · 1096 阅读 · 0 评论 -
if的三元运算符和列表解析、字典解析
1、三元运算(三目运算)对简单的条件语句,可以用三元运算简写。三元运算只能写在一行代码里面# 书写格式result = 值1 if 条件 else 值2 # 如果条件成立,那么将 “值1” 赋值给result变量,否则,将“值2”赋值给result变量examples:result = 'the result if the if succeeds' if o转载 2018-01-08 14:14:37 · 465 阅读 · 0 评论 -
Pandas分组统计函数:groupby、pivot_table及crosstab
转自:http://blog.youkuaiyun.com/elecjack/article/details/50760736利用python的pandas库进行数据分组分析十分便捷,其中应用最多的方法包括:groupby、pivot_table及crosstab,以下分别进行介绍。0、样例数据[python] view plain copy转载 2018-01-17 15:04:27 · 1148 阅读 · 1 评论 -
Python--matplotlib绘图可视化知识点整理
转自:https://www.cnblogs.com/zhizhan/p/5615947.html无论你工作在什么项目上,IPython都是值得推荐的。利用ipython --pylab,可以进入PyLab模式,已经导入了matplotlib库与相关软件包(例如Numpy和Scipy),额可以直接使用相关库的功能。本文作为学习过程中对matplotlib一些常用知识点的转载 2018-01-17 15:21:07 · 490 阅读 · 0 评论 -
Matplotlib.pyplot 用法 1
"""@author: Vincnet_Sheng@file: Matploitlib-1.py@time: 2018/1/6 0006 下午 2:24#-*- coding: utf-8 -*"""# Target:1) 掌握fiture()产生图像,并可以编号# 2)掌握plot函数的用法,包括(label, color, width, linestyle)#原创 2018-01-07 00:15:27 · 465 阅读 · 0 评论 -
Python 字符串格式化 (%操作符)
在许多编程语言中都包含有格式化字符串的功能,比如C和Fortran语言中的格式化输入输出。Python中内置有对字符串进行格式化的操作%。 模板格式化字符串时,Python使用一个字符串作为模板。模板中有格式符,这些格式符为真实值预留位置,并说明真实数值应该呈现的格式。Python用一个tuple将多个值传递给模板,每个值对应一个格式符。比如下面的例子:pr转载 2018-01-06 19:07:48 · 563 阅读 · 0 评论 -
linspace函数
numpy.linspace是用于创建一个一维数组,并且是等差数列构成的一维数组,下面这篇文章主要给大家介绍了关于python numpy函数中的linspace创建等差数列的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下。numpy.linspace 是用于创建一个由等差数列构成的一维数组。它最长用的有三个参数,当然不止三个。常用参数:第一个例子,用到转载 2018-01-06 14:36:15 · 3921 阅读 · 0 评论 -
zip函数用法
zip函数的原型为:zip([iterable, …])参数iterable为可迭代的对象,并且可以有多个参数。该函数返回一个以元组为元素的列表,其中第 i 个元组包含每个参数序列的第 i 个元素。返回的列表长度被截断为最短的参数序列的长度。只有一个序列参数时,它返回一个1元组的列表。没有参数时,它返回一个空的列表。import numpy as npa=[1,2,3,4,5]b=转载 2018-01-11 23:50:47 · 545 阅读 · 0 评论 -
round函数
描述round() 方法返回保留n位小数后,浮点数x的四舍五入值。语法以下是 round() 方法的语法:round( x [, n] )参数x -- 数值表达式。n -- 保留小数个数。返回值返回浮点数x的四舍五入值。round(80.23456, 2) : 80.23round(100.000056,转载 2018-01-12 00:28:29 · 707 阅读 · 0 评论 -
*和**的用法,用作实参:Unpacking Argument Lists
The reverse situation occurs when the arguments are already in a list or tuple but need to be unpacked for a function call requiring separate positional arguments. For instance, the built-in range() f转载 2018-01-12 00:53:47 · 300 阅读 · 0 评论 -
del statement
5.2. The del statementThere is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop() method which returns a value. The del stat转载 2018-01-12 01:04:53 · 216 阅读 · 0 评论 -
数据结构:List常用操作
Reference:Python官方Document Tutorialhttps://docs.python.org/3/reference/datamodel.html#object.__contains__ This chapter describes some things you’ve learned about already in more detail, and ad转载 2018-01-11 20:11:13 · 797 阅读 · 0 评论 -
数据结构 tuple 和 sequence讲解,以及常用操作
5.3. Tuples and SequencesWe saw that lists and strings have many common properties, such as indexing and slicing operations. They are two examples of sequence data types (see Sequence Types — li转载 2018-01-12 01:10:17 · 1113 阅读 · 0 评论 -
数据结构:Dictionary 常用方法
1.dic.clear()删除字典中所有项2.dic.fromkeys(S[,v])新建字典,键为S,值为v,如果S为长字符串,返回的键为字符串中的每一个字符,值将重复。注意:dic字典中的项不会改变3.dic.get(k[,d])获取字典中指定键的值,如果k不属于字典中的键,则返回None。注意:相当于dic[k],但是dic[k]如果k不属于字典中的键,转载 2018-01-12 01:39:13 · 2115 阅读 · 0 评论 -
sort, sorted, argsort对list和dict进行排序
iterable:是可迭代类型;cmp:用于比较的函数,比较什么由key决定;key:用列表元素的某个属性或函数进行作为关键字,有默认值,迭代集合中的一项;reverse:排序规则. reverse = True 降序 或者 reverse = False 升序,有默认值。返回值:是一个经过排序的可迭代类型,与iterable一样。1. sort, sorted, 和转载 2018-01-08 09:41:23 · 561 阅读 · 0 评论 -
range函数
Python range() 函数用法 Python 内置函数pytho range() 函数创建一个range对象,可用list()返回一个整数列表,一般用在 for 循环中。函数语法range(start, stop[, step])参数说明:start: 计数从 start 开始。默认是从 0 开始。例如range(5)等价于range(0转载 2018-01-06 13:52:11 · 7313 阅读 · 0 评论 -
'in’ key word, which is Membership test operation
key word in: This tests whether or not a sequence contains a certain value.example: def ask_ok(prompt, retries=4, reminder='Please try again!'): while True: ok = input(prompt)转载 2018-01-10 19:37:51 · 219 阅读 · 0 评论