diff --git a/Day01-15/01.初识Python.md b/Day01-15/01.初识Python.md index 05acd85..50f7e3c 100644 --- a/Day01-15/01.初识Python.md +++ b/Day01-15/01.初识Python.md @@ -10,33 +10,31 @@ 4. 2000年10月16日:Python 2.0发布,增加了完整的[垃圾回收](https://zh.wikipedia.org/wiki/%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6_(%E8%A8%88%E7%AE%97%E6%A9%9F%E7%A7%91%E5%AD%B8)),提供了对[Unicode](https://zh.wikipedia.org/wiki/Unicode)的支持。与此同时,Python的整个开发过程更加透明,社区对开发进度的影响逐渐扩大,生态圈开始慢慢形成。 5. 2008年12月3日:Python 3.0发布,它并不完全兼容之前的Python代码,不过因为目前还有不少公司在项目和运维中使用Python 2.x版本,所以Python 3.x的很多新特性后来也被移植到Python 2.6/2.7版本中。 -目前我们使用的Python 3.7.x的版本是在2018年发布的,Python的版本号分为三段,形如A.B.C。其中A表示大版本号,一般当整体重写,或出现不向后兼容的改变时,增加A;B表示功能更新,出现新功能时增加B;C表示小的改动(例如:修复了某个Bug),只要有修改就增加C。如果对Python的历史感兴趣,可以阅读名为[《Python简史》](http://www.cnblogs.com/vamei/archive/2013/02/06/2892628.html)的博文。 +目前我们使用的Python 3.7.x的版本是在2018年发布的,Python的版本号分为三段,形如A.B.C。其中A表示大版本号,一般当整体重写,或出现不向后兼容的改变时,增加A;B表示功能更新,出现新功能时增加B;C表示小的改动(例如:修复了某个Bug),只要有修改就增加C。如果对Python的历史感兴趣,可以阅读名为[《Python简史》](http://www.cnblogs.com/vamei/archive/2013/02/06/2892628.html)的网络文章。 #### Python的优缺点 Python的优点很多,简单的可以总结为以下几点。 -1. 简单和明确,做一件事只有一种方法。 -2. 学习曲线低,跟其他很多语言相比,Python更容易上手。 -3. 开放源代码,拥有强大的社区和生态圈。 -4. 解释型语言,天生具有平台可移植性。 -5. 对两种主流的编程范式(面向对象编程和函数式编程)都提供了支持。 -6. 可扩展性和可嵌入性,例如在Python中可以调用C/C++代码。 -7. 代码规范程度高,可读性强,适合有代码洁癖和强迫症的人群。 +1. 简单明了,学习曲线低,比很多编程语言都容易上手。 +2. 开放源代码,拥有强大的社区和生态圈,尤其是在数据分析和机器学习领域。 +3. 解释型语言,天生具有平台可移植性,代码可以工作于不同的操作系统。 +4. 对两种主流的编程范式(面向对象编程和函数式编程)都提供了支持。 +5. 代码规范程度高,可读性强,适合有代码洁癖和强迫症的人群。 Python的缺点主要集中在以下几点。 -1. 执行效率稍低,因此计算密集型任务可以由C/C++编写。 +1. 执行效率稍低,对执行效率要求高的部分可以由其他语言(如:C、C++)编写。 2. 代码无法加密,但是现在很多公司都不销售卖软件而是销售服务,这个问题会被弱化。 3. 在开发时可以选择的框架太多(如Web框架就有100多个),有选择的地方就有错误。 #### Python的应用领域 -目前Python在Web应用开发、云基础设施、DevOps、网络数据采集(爬虫)、数据分析挖掘、机器学习等领域都有着广泛的应用,因此也产生了Web后端开发、数据接口开发、自动化运维、自动化测试、科学计算和可视化、数据分析、量化交易、机器人开发、自然语言处理、图像识别等一系列相关的职位。 +目前Python在Web应用后端开发、云基础设施建设、DevOps、网络数据采集(爬虫)、自动化测试、数据分析、机器学习等领域都有着广泛的应用。 ### 安装Python解释器 -想要开始Python编程之旅,首先得在自己使用的计算机上安装Python解释器环境,下面将以安装官方的Python解释器为例,讲解如何在不同的操作系统上安装Python环境。官方的Python解释器是用C语言实现的,也是使用最为广泛的Python解释器,通常称之为CPython。除此之外,Python解释器还有Java语言实现的Jython、C#语言实现的IronPython以及PyPy、Brython、Pyston等版本,我们暂时不对这些内容进行介绍,有兴趣的读者可以自行了解。 +想要开始Python编程之旅,首先得在自己使用的计算机上安装Python解释器环境,下面将以安装官方的Python解释器为例,讲解如何在不同的操作系统上安装Python环境。官方的Python解释器是用C语言实现的,也是使用最为广泛的Python解释器,通常称之为CPython。除此之外,Python解释器还有Java语言实现的Jython、C#语言实现的IronPython以及PyPy、Brython、Pyston等版本,有兴趣的读者可以自行了解。 #### Windows环境 @@ -57,15 +55,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit 2. 下载Python源代码并解压缩到指定目录。 ```Shell -wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz -xz -d Python-3.7.3.tar.xz -tar -xvf Python-3.7.3.tar +wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz +xz -d Python-3.7.6.tar.xz +tar -xvf Python-3.7.6.tar ``` 3. 切换至Python源代码目录并执行下面的命令进行配置和安装。 ```Shell -cd Python-3.7.3 +cd Python-3.7.6 ./configure --prefix=/usr/local/python37 --enable-optimizations make && make install ``` @@ -104,13 +102,13 @@ macOS也自带了Python 2.x版本,可以通过[Python的官方网站](https:// ```Shell python --version ``` -或者是在Linux或macOS系统的终端中键入下面的命令。 +在Linux或macOS系统的终端中键入下面的命令。 ```Shell python3 --version ``` -当然也可以先输入python或python3进入交互式环境,再执行以下的代码检查Python的版本。 +当然也可以先输入`python`或`python3`进入交互式环境,再执行以下的代码检查Python的版本。 ```Python import sys @@ -156,12 +154,8 @@ python3 hello.py Version: 0.1 Author: 骆昊 """ - print('hello, world!') -# print("你好,世界!") -print('你好', '世界') -print('hello', 'world', sep=', ', end='!') -print('goodbye, world', end='!\n') +# print("你好, 世界!") ``` ### Python开发工具 @@ -174,7 +168,7 @@ IDLE是安装Python环境时自带的集成开发工具,如下图所示。但 #### IPython - 更好的交互式编程工具 -IPython是一种基于Python的交互式解释器。相较于原生的Python交互式环境,IPython提供了更为强大的编辑和交互功能。可以通过Python的包管理工具pip安装IPython和Jupyter,具体的操作如下所示。 +IPython是一种基于Python的交互式解释器。相较于原生的Python交互式环境,IPython提供了更为强大的编辑和交互功能。可以通过Python的包管理工具pip安装IPython,具体的操作如下所示。 ```Shell pip install ipython @@ -220,7 +214,7 @@ pip3 install ipython - Python PEP8 Autoformat - PEP8规范自动格式化插件。 - ConvertToUTF8 - 将本地编码转换为UTF-8。 -> 说明:事实上[Visual Studio Code]()可能是更好的选择,它不用花钱并提供了更为完整和强大的功能,有兴趣的读者可以自行研究。 +> **说明**:事实上[Visual Studio Code]()可能是更好的选择,它不用花钱并提供了更为完整和强大的功能,有兴趣的读者可以自行研究。 #### PyCharm - Python开发神器 @@ -236,12 +230,11 @@ PyCharm的安装、配置和使用在[《玩转PyCharm》](../玩转PyCharm.md) import this ``` - > 说明:输入上面的代码,在Python的交互式环境中可以看到Tim Peter撰写的[“Python之禅”](../Python之禅.md),里面讲述的道理不仅仅适用于Python,也适用于其他编程语言。 - > + > **说明**:输入上面的代码,在Python的交互式环境中可以看到Tim Peter撰写的[“Python之禅”](../Python之禅.md),里面讲述的道理不仅仅适用于Python,也适用于其他编程语言。 2. 学习使用turtle在屏幕上绘制图形。 - > 说明:turtle是Python内置的一个非常有趣的模块,特别适合对计算机程序设计进行初体验的小伙伴,它最早是Logo语言的一部分,Logo语言是Wally Feurzig和Seymour Papert在1966发明的编程语言。 + > **说明**:turtle是Python内置的一个非常有趣的模块,特别适合对计算机程序设计进行初体验的小伙伴,它最早是Logo语言的一部分,Logo语言是Wally Feurzig和Seymour Papert在1966发明的编程语言。 ```Python import turtle @@ -260,4 +253,4 @@ PyCharm的安装、配置和使用在[《玩转PyCharm》](../玩转PyCharm.md) turtle.mainloop() ``` - > 提示:本章提供的代码中还有画国旗和画小猪佩奇的代码,有兴趣的读者请自行研究。 + > **提示**:本章提供的代码中还有画国旗和画小猪佩奇的代码,有兴趣的读者请自行研究。 diff --git a/Day01-15/02.语言元素.md b/Day01-15/02.语言元素.md index 65d3dd9..bdb7f13 100644 --- a/Day01-15/02.语言元素.md +++ b/Day01-15/02.语言元素.md @@ -4,17 +4,17 @@ 计算机的硬件系统通常由五大部件构成,包括:运算器、控制器、存储器、输入设备和输出设备。其中,运算器和控制器放在一起就是我们通常所说的中央处理器,它的功能是执行各种运算和控制指令以及处理计算机软件中的数据。我们通常所说的程序实际上就是指令的集合,我们程序就是将一系列的指令按照某种方式组织到一起,然后通过这些指令去控制计算机做我们想让它做的事情。今天我们大多数时候使用的计算机,虽然它们的元器件做工越来越精密,处理能力越来越强大,但究其本质来说仍然属于[“冯·诺依曼结构”](https://zh.wikipedia.org/wiki/%E5%86%AF%C2%B7%E8%AF%BA%E4%BC%8A%E6%9B%BC%E7%BB%93%E6%9E%84)的计算机。“冯·诺依曼结构”有两个关键点,一是指出要将存储设备与中央处理器分开,二是提出了将数据以二进制方式编码。二进制是一种“逢二进一”的计数法,跟我们人类使用的“逢十进一”的计数法没有实质性的区别,人类因为有十根手指所以使用了十进制(因为在数数时十根手指用完之后就只能进位了,当然凡事都有例外,玛雅人可能是因为长年光着脚的原因把脚趾头也算上了,于是他们使用了二十进制的计数法,在这种计数法的指导下玛雅人的历法就与我们平常使用的历法不一样,而按照玛雅人的历法,2012年是上一个所谓的“太阳纪”的最后一年,而2013年则是新的“太阳纪”的开始,后来这件事情被以讹传讹的方式误传为”2012年是玛雅人预言的世界末日“这种荒诞的说法,今天我们可以大胆的猜测,玛雅文明之所以发展缓慢估计也与使用了二十进制有关)。对于计算机来说,二进制在物理器件上来说是最容易实现的(高电压表示1,低电压表示0),于是在“冯·诺依曼结构”的计算机都使用了二进制。虽然我们并不需要每个程序员都能够使用二进制的思维方式来工作,但是了解二进制以及它与我们生活中的十进制之间的转换关系,以及二进制与八进制和十六进制的转换关系还是有必要的。如果你对这一点不熟悉,可以自行使用[维基百科](https://zh.wikipedia.org/wiki/%E4%BA%8C%E8%BF%9B%E5%88%B6)或者[百度百科](https://baike.baidu.com)科普一下。 -> 提示:近期关于**量子计算机**的研究已经被推倒了风口浪尖,量子计算机基于量子力学进行运算,使用量子瞬移的方式来传递信息。2018年6月,Intel宣布开发出新款量子芯片并通过了在接近绝对零度环境下的测试;2019年1月,IBM向全世界发布了首款商业化量子计算机。 +> **说明**:近期关于**量子计算机**的研究已经被推倒了风口浪尖,量子计算机基于量子力学进行运算,使用量子瞬移的方式来传递信息。2018年6月,Intel宣布开发出新款量子芯片并通过了在接近绝对零度环境下的测试;2019年,IBM和Google都推出了自己的量子计算机。 ### 变量和类型 在程序设计中,变量是一种存储数据的载体。计算机中的变量是实际存在的数据或者说是存储器中存储数据的一块内存空间,变量的值可以被读取和修改,这是所有计算和控制的基础。计算机能处理的数据有很多种类型,除了数值之外还可以处理文本、图形、音频、视频等各种各样的数据,那么不同的数据就需要定义不同的存储类型。Python中的数据类型很多,而且也允许我们自定义新的数据类型(这一点在后面会讲到),我们先介绍几种常用的数据类型。 -- 整型:Python中可以处理任意大小的整数(Python 2.x中有int和long两种类型的整数,但这种区分对Python来说意义不大,因此在Python 3.x中整数只有int这一种了),而且支持二进制(如`0b100`,换算成十进制是4)、八进制(如`0o100`,换算成十进制是64)、十进制(`100`)和十六进制(`0x100`,换算成十进制是256)的表示法。 +- 整型:Python中可以处理任意大小的整数(Python 2.x中有`int`和`long`两种类型的整数,但这种区分对Python来说意义不大,因此在Python 3.x中整数只有int这一种了),而且支持二进制(如`0b100`,换算成十进制是4)、八进制(如`0o100`,换算成十进制是64)、十进制(`100`)和十六进制(`0x100`,换算成十进制是256)的表示法。 - 浮点型:浮点数也就是小数,之所以称为浮点数,是因为按照科学记数法表示时,一个浮点数的小数点位置是可变的,浮点数除了数学写法(如`123.456`)之外还支持科学计数法(如`1.23456e2`)。 - 字符串型:字符串是以单引号或双引号括起来的任意文本,比如`'hello'`和`"hello"`,字符串还有原始字符串表示法、字节字符串表示法、Unicode字符串表示法,而且可以书写成多行的形式(用三个单引号或三个双引号开头,三个单引号或三个双引号结尾)。 - 布尔型:布尔值只有`True`、`False`两种值,要么是`True`,要么是`False`,在Python中,可以直接用`True`、`False`表示布尔值(请注意大小写),也可以通过布尔运算计算出来(例如`3 < 5`会产生布尔值`True`,而`2 == 1`会产生布尔值`False`)。 -- 复数型:形如`3+5j`,跟数学上的复数表示一样,唯一不同的是虚部的`i`换成了`j`。实际上,这个类型并不能算作常用类型,大家了解下就可以了。 +- 复数型:形如`3+5j`,跟数学上的复数表示一样,唯一不同的是虚部的`i`换成了`j`。实际上,这个类型并不常用,大家了解一下就可以了。 #### 变量命名 @@ -37,21 +37,17 @@ ```Python """ -使用变量保存数据并进行算术运算 +使用变量保存数据并进行加减乘除运算 Version: 0.1 Author: 骆昊 """ - a = 321 -b = 123 -print(a + b) -print(a - b) -print(a * b) -print(a / b) -print(a // b) -print(a % b) -print(a ** b) +b = 12 +print(a + b) # 333 +print(a - b) # 309 +print(a * b) # 3852 +print(a / b) # 26.75 ``` 在Python中可以使用`type`函数对变量的类型进行检查。程序设计中函数的概念跟数学上函数的概念是一致的,数学上的函数相信大家并不陌生,它包括了函数名、自变量和因变量。如果暂时不理解这个概念也不要紧,我们会在后续的章节中专门讲解函数的定义和使用。 @@ -62,19 +58,17 @@ print(a ** b) Version: 0.1 Author: 骆昊 -Date: 2018-02-27 """ - a = 100 b = 12.345 c = 1 + 5j d = 'hello, world' e = True -print(type(a)) # -print(type(b)) # -print(type(c)) # -print(type(d)) # -print(type(e)) # +print(type(a)) # +print(type(b)) # +print(type(c)) # +print(type(d)) # +print(type(e)) # ``` 可以使用Python中内置的函数对变量类型进行转换。 @@ -96,7 +90,6 @@ print(type(e)) # Version: 0.1 Author: 骆昊 """ - a = int(input('a = ')) b = int(input('b = ')) print('%d + %d = %d' % (a, b, a + b)) @@ -133,7 +126,9 @@ Python支持多种运算符,下表大致按照优先级从高到低的顺序 >**说明:** 在实际开发中,如果搞不清楚运算符的优先级,可以使用括号来确保运算的执行顺序。 -下面的例子演示了赋值运算符和复合赋值运算符的使用。 +#### 赋值运算符 + +赋值运算符应该是最为常见的运算符,它的作用是将右边的值赋给左边的变量。下面的例子演示了赋值运算符和复合赋值运算符的使用。 ```Python """ @@ -142,40 +137,42 @@ Python支持多种运算符,下表大致按照优先级从高到低的顺序 Version: 0.1 Author: 骆昊 """ - a = 10 b = 3 -a += b # 相当于:a = a + b -a *= a + 2 # 相当于:a = a * (a + 2) -print(a) # 想想这里会输出什么 +a += b # 相当于:a = a + b +a *= a + 2 # 相当于:a = a * (a + 2) +print(a) # 算一下这里会输出什么 ``` -下面的例子演示了比较运算符(关系运算符)、逻辑运算符和身份运算符的使用。 +### 比较运算符和逻辑运算符 + +比较运算符有的地方也称为关系运算符,包括`==`、`!=`、`<`、`>`、`<=`、`>=`,我相信没有什么好解释的,大家一看就能懂,唯一需要提醒的是比较相等用的是`==`,请注意这个地方是两个等号,因为`=`是赋值运算符,我们在上面刚刚讲到过,`==`才是比较相等的比较运算符。比较运算符会产生布尔值,要么是`True`要么是`False`。 + +逻辑运算符有三个,分别是`and`、`or`和`not`。`and`字面意思是“而且”,所以`and`运算符会连接两个布尔值,如果两个布尔值都是`True`,那么运算的结果就是`True`;左右两边的布尔值有一个是`False`,最终的运算结果就是`False`。相信大家已经想到了,如果`and`左边的布尔值是`False`,不管右边的布尔值是什么,最终的结果都是`False`,所以在做运算的时候右边的值会被跳过(短路处理),这也就意味着在`and`运算符左边为`False`的情况下,右边的表达式根本不会执行。`or`字面意思是“或者”,所以`or`运算符也会连接两个布尔值,如果两个布尔值有任意一个是`True`,那么最终的结果就是`True`。当然,`or`运算符也是有短路功能的,在它左边的布尔值为`True`的情况下,右边的表达式根本不会执行。`not`运算符的后面会跟上一个布尔值,它的作用是得到与该布尔值相反的值,也就是说,后面的布尔值如果是`True`运算结果就是`False`,而后面的布尔值如果是`False`则运算结果就是`True`。 ```Python """ -比较、逻辑和算身份运算符的使用 +比较运算符和逻辑运算符的使用 Version: 0.1 Author: 骆昊 """ - flag0 = 1 == 1 flag1 = 3 > 2 flag2 = 2 < 1 flag3 = flag1 and flag2 flag4 = flag1 or flag2 flag5 = not (1 != 2) -print('flag0 =', flag0) # flag0 = True -print('flag1 =', flag1) # flag1 = True -print('flag2 =', flag2) # flag2 = False -print('flag3 =', flag3) # flag3 = False -print('flag4 =', flag4) # flag4 = True -print('flag5 =', flag5) # flag5 = False -print(flag1 is True) # True -print(flag2 is not False) # False +print('flag0 =', flag0) # flag0 = True +print('flag1 =', flag1) # flag1 = True +print('flag2 =', flag2) # flag2 = False +print('flag3 =', flag3) # flag3 = False +print('flag4 =', flag4) # flag4 = True +print('flag5 =', flag5) # flag5 = False ``` +> **说明**:比较运算符的优先级高于赋值运算符,所以`flag0 = 1 == 1`先做`1 == 1`产生布尔值`True`,再将这个值赋值给变量`flag0`。`print`函数可以输出多个值,多个值之间可以用`,`进行分隔,输出的内容之间默认以空格分开。 + ### 练习 #### 练习1:华氏温度转换为摄氏温度。 @@ -191,12 +188,17 @@ print(flag2 is not False) # False Version: 0.1 Author: 骆昊 """ - f = float(input('请输入华氏温度: ')) c = (f - 32) / 1.8 print('%.1f华氏度 = %.1f摄氏度' % (f, c)) ``` +> **说明**:在使用`print`函数输出时,也可以对字符串内容进行格式化处理,上面`print`函数中的字符串`%1.f`是一个占位符,稍后会由一个`float`类型的变量值替换掉它。同理,如果字符串中有`%d`,后面可以用一个`int`类型的变量值替换掉它,而`%s`会被字符串的值替换掉。除了这种格式化字符串的方式外,还可以用下面的方式来格式化字符串,其中`{f:.1f}`和`{c:.1f}`可以先看成是`{f}`和`{c}`,表示输出时会用变量`f`和变量`c`的值替换掉这两个占位符,后面的`:.1f`表示这是一个浮点数,小数点后保留1位有效数字。 +> +> ```Python +> print(f'{f:.1f}华氏度 = {c:.1f}摄氏度') +> ``` + #### 练习2:输入圆的半径计算计算周长和面积。 参考答案: @@ -208,12 +210,9 @@ print('%.1f华氏度 = %.1f摄氏度' % (f, c)) Version: 0.1 Author: 骆昊 """ - -import math - radius = float(input('请输入圆的半径: ')) -perimeter = 2 * math.pi * radius -area = math.pi * radius * radius +perimeter = 2 * 3.1416 * radius +area = 3.1416 * radius * radius print('周长: %.2f' % perimeter) print('面积: %.2f' % area) ``` @@ -229,11 +228,11 @@ print('面积: %.2f' % area) Version: 0.1 Author: 骆昊 """ - year = int(input('请输入年份: ')) # 如果代码太长写成一行不便于阅读 可以使用\对代码进行折行 -is_leap = (year % 4 == 0 and year % 100 != 0) or \ - year % 400 == 0 +is_leap = year % 4 == 0 and year % 100 != 0 or \ + year % 400 == 0 print(is_leap) ``` +> **说明**:比较运算符会产生布尔值,而逻辑运算符`and`和`or`会对这些布尔值进行组合,最终也是得到一个布尔值,闰年输出`True`,平年输出`False`。 \ No newline at end of file diff --git a/Day01-15/03.分支结构.md b/Day01-15/03.分支结构.md index e69246b..abd08e7 100644 --- a/Day01-15/03.分支结构.md +++ b/Day01-15/03.分支结构.md @@ -15,7 +15,6 @@ Version: 0.1 Author: 骆昊 """ - username = input('请输入用户名: ') password = input('请输入口令: ') # 用户名是admin且密码是123456则身份验证成功否则身份验证失败 @@ -25,9 +24,9 @@ else: print('身份验证失败!') ``` -唯一需要说明的是和C/C++、Java等语言不同,Python中没有用花括号来构造代码块而是使用了缩进的方式来设置代码的层次结构,如果`if`条件成立的情况下需要执行多条语句,只要保持多条语句具有相同的缩进就可以了,换句话说连续的代码如果又保持了相同的缩进那么它们属于同一个代码块,相当于是一个执行的整体。 +需要说明的是和C/C++、Java等语言不同,Python中没有用花括号来构造代码块而是**使用了缩进的方式来表示代码的层次结构**,如果`if`条件成立的情况下需要执行多条语句,只要保持多条语句具有相同的缩进就可以了。换句话说**连续的代码如果又保持了相同的缩进那么它们属于同一个代码块**,相当于是一个执行的整体。**缩进**可以使用任意数量的空格,但**通常使用4个空格**,建议大家**不要使用制表键**或者**设置你的代码编辑工具自动将制表键变成4个空格**。 -当然如果要构造出更多的分支,可以使用`if…elif…else…`结构,例如下面的分段函数求值。 +当然如果要构造出更多的分支,可以使用`if...elif...else...`结构或者嵌套的`if...else...`结构,下面的代码演示了如何利用多分支结构实现分段函数求值。 ![$$f(x)=\begin{cases} 3x-5&\text{(x>1)}\\x+2&\text{(-1}\leq\text{x}\leq\text{1)}\\5x+3&\text {(x<-1)}\end{cases}$$](./res/formula_1.png) @@ -92,7 +91,6 @@ print('f(%.2f) = %.2f' % (x, y)) Version: 0.1 Author: 骆昊 """ - value = float(input('请输入长度: ')) unit = input('请输入单位: ') if unit == 'in' or unit == '英寸': @@ -116,7 +114,6 @@ else: Version: 0.1 Author: 骆昊 """ - score = float(input('请输入成绩: ')) if score >= 90: grade = 'A' @@ -141,7 +138,6 @@ print('对应的等级是:', grade) Version: 0.1 Author: 骆昊 """ - a = float(input('a = ')) b = float(input('b = ')) c = float(input('c = ')) diff --git a/Day01-15/04.循环结构.md b/Day01-15/04.循环结构.md index 4415720..7bc33f9 100644 --- a/Day01-15/04.循环结构.md +++ b/Day01-15/04.循环结构.md @@ -2,9 +2,9 @@ ### 应用场景 -如果在程序中我们需要重复的执行某条或某些指令,例如用程序控制机器人踢足球,如果机器人持球而且还没有进入射门范围,那么我们就要一直发出让机器人向球门方向奔跑的指令。当然你可能已经注意到了,刚才的描述中不仅仅有需要重复的动作,还需要用到上一章讲的分支结构。再举一个简单的例子,我们要实现一个每隔1秒中在屏幕上打印一次"hello, world"并持续打印一个小时的程序,我们肯定不能够直接把`print('hello, world')`这句代码写3600遍,如果真的要这样做,那么编程的工作就太无聊乏味了。因此,我们还需要了解一下循环结构,有了循环结构我们就可以轻松的控制某件事或者某些事重复、重复、再重复的去执行。 +我们在写程序的时候,一定会遇到需要重复执行某条或某些指令的场景。例如用程序控制机器人踢足球,如果机器人持球而且还没有进入射门范围,那么我们就要一直发出让机器人向球门方向移动的指令。在这个场景中,让机器人向球门方向移动就是一个需要重复的动作,当然这里还会用到上一课讲的分支结构来判断机器人是否持球以及是否进入射门范围。再举一个简单的例子,如果要实现每隔1秒中在屏幕上打印一次“hello, world”并持续打印一个小时,我们肯定不能够直接把`print('hello, world')`这句代码写3600遍,这里同样需要循环结构。 -在Python中构造循环结构有两种做法,一种是`for-in`循环,一种是`while`循环。 +循环结构就是程序中控制某条或某些指令重复执行的结构。在Python中构造循环结构有两种做法,一种是`for-in`循环,一种是`while`循环。 ### for-in循环 @@ -24,11 +24,12 @@ for x in range(101): print(sum) ``` -需要说明的是上面代码中的`range(101)`可以用来构造一个从0到100的取值范围,这样就可以构造出一个整数的序列并用于循环中,例如: +需要说明的是上面代码中的`range(1, 101)`可以用来构造一个从1到100的范围,当我们把这样一个范围放到`for-in`循环中,就可以通过前面的循环变量`x`依次取出从1到100的整数。当然,`range`的用法非常灵活,下面给出了一个例子: -- `range(101)`可以产生一个0到100的整数序列。 -- `range(1, 100)`可以产生一个1到99的整数序列。 -- `range(1, 100, 2)`可以产生一个1到99的奇数序列,其中2是步长,即数值序列的增量。 +- `range(101)`:可以用来产生0到100范围的整数,需要注意的是取不到101。 +- `range(1, 101)`:可以用来产生1到100范围的整数,相当于前面是闭区间后面是开区间。 +- `range(1, 101, 2)`:可以用来产生1到100的奇数,其中2是步长,即每次数值递增的值。 +- `range(100, 0, -2)`:可以用来产生100到1的偶数,其中-2是步长,即每次数字递减的值。 知道了这一点,我们可以用下面的代码来实现1~100之间的偶数求和。 @@ -46,7 +47,7 @@ for x in range(2, 101, 2): print(sum) ``` -也可以通过在循环中使用分支结构的方式来实现相同的功能,代码如下所示。 +当然,也可以通过在循环中使用分支结构的方式来实现相同的功能,代码如下所示。 ```Python """ @@ -63,20 +64,21 @@ for x in range(1, 101): print(sum) ``` +> **说明**:相较于上面直接跳过奇数的做法,下面这种做法很明显并不是很好的选择。 + ### while循环 -如果要构造不知道具体循环次数的循环结构,我们推荐使用`while`循环。`while`循环通过一个能够产生或转换出`bool`值的表达式来控制循环,表达式的值为`True`循环继续,表达式的值为`False`循环结束。下面我们通过一个“猜数字”的小游戏(计算机出一个1~100之间的随机数,人输入自己猜的数字,计算机给出对应的提示信息,直到人猜出计算机出的数字)来看看如何使用`while`循环。 +如果要构造不知道具体循环次数的循环结构,我们推荐使用`while`循环。`while`循环通过一个能够产生或转换出`bool`值的表达式来控制循环,表达式的值为`True`则继续循环;表达式的值为`False`则结束循环。 + +下面我们通过一个“猜数字”的小游戏来看看如何使用`while`循环。猜数字游戏的规则是:计算机出一个1到100之间的随机数,玩家输入自己猜的数字,计算机给出对应的提示信息(大一点、小一点或猜对了),如果玩家猜中了数字,计算机提示用户一共猜了多少次,游戏结束,否则游戏继续。 ```Python """ 猜数字游戏 -计算机出一个1~100之间的随机数由人来猜 -计算机根据人猜的数字分别给出提示大一点/小一点/猜对了 Version: 0.1 Author: 骆昊 """ - import random answer = random.randint(1, 100) @@ -147,6 +149,8 @@ else: #### 练习2:输入两个正整数,计算它们的最大公约数和最小公倍数。 +> **提示**:两个数的最大公约数是两个数的公共因子中最大的那个数;两个数的最小公倍数则是能够同时被两个数整除的最小的那个数。 + 参考答案: ```Python diff --git a/Day01-15/06.函数和模块的使用.md b/Day01-15/06.函数和模块的使用.md index 4badd51..11d5099 100644 --- a/Day01-15/06.函数和模块的使用.md +++ b/Day01-15/06.函数和模块的使用.md @@ -17,7 +17,6 @@ Version: 0.1 Author: 骆昊 """ - m = int(input('m = ')) n = int(input('n = ')) fm = 1 @@ -26,10 +25,10 @@ for num in range(1, m + 1): fn = 1 for num in range(1, n + 1): fn *= num -fmn = 1 +fm_n = 1 for num in range(1, m - n + 1): - fmn *= num -print(fm // fn // fmn) + fm_n *= num +print(fm // fn // fm_n) ``` ### 函数的作用 @@ -43,7 +42,13 @@ print(fm // fn // fmn) 在了解了如何定义函数后,我们可以对上面的代码进行重构,所谓重构就是在不影响代码执行结果的前提下对代码的结构进行调整,重构之后的代码如下所示。 ```Python -def factorial(num): +""" +输入M和N计算C(M,N) + +Version: 0.1 +Author: 骆昊 +""" +def fac(num): """求阶乘""" result = 1 for n in range(1, num + 1): @@ -54,10 +59,10 @@ def factorial(num): m = int(input('m = ')) n = int(input('n = ')) # 当需要计算阶乘的时候不用再写循环求阶乘而是直接调用已经定义好的函数 -print(factorial(m) // factorial(n) // factorial(m - n)) +print(fac(m) // fac(n) // fac(m - n)) ``` -> **说明:** Python的`math`模块中其实已经有一个`factoria`l函数了,事实上要计算阶乘可以直接使用这个现成的函数而不用自己定义。下面例子中的一些函数在Python中也都是现成的,我们这里是为了讲解函数的定义和使用才把它们又实现了一遍,实际开发中不建议做这种低级的重复性的工作。 +> **说明:** Python的`math`模块中其实已经有一个名为`factorial`函数实现了阶乘运算,事实上求阶乘并不用自己定义函数。下面的例子中,我们讲的函数在Python标准库已经实现过了,我们这里是为了讲解函数的定义和使用才把它们又实现了一遍,**实际开发中并不建议做这种低级的重复劳动**。 ### 函数的参数 @@ -267,7 +272,7 @@ def is_palindrome(num): ```Python def is_prime(num): """判断一个数是不是素数""" - for factor in range(2, num): + for factor in range(2, int(num ** 0.5) + 1): if num % factor == 0: return False return True if num != 1 else False @@ -286,6 +291,8 @@ if __name__ == '__main__': > **注意**:通过上面的程序可以看出,当我们**将代码中重复出现的和相对独立的功能抽取成函数**后,我们可以**组合使用这些函数**来解决更为复杂的问题,这也是我们为什么要定义和使用函数的一个非常重要的原因。 +### 变量的作用域 + 最后,我们来讨论一下Python中有关变量作用域的问题。 ```Python diff --git a/Day01-15/12.字符串和正则表达式.md b/Day01-15/12.字符串和正则表达式.md index b8b9ae9..088cc58 100644 --- a/Day01-15/12.字符串和正则表达式.md +++ b/Day01-15/12.字符串和正则表达式.md @@ -32,7 +32,7 @@ | \| | 分支 | foo\|bar | 可以匹配foo或者bar | | (?#) | 注释 | | | | (exp) | 匹配exp并捕获到自动命名的组中 | | | -| (? <name>exp) | 匹配exp并捕获到名为name的组中 | | | +| (?<name>exp) | 匹配exp并捕获到名为name的组中 | | | | (?:exp) | 匹配exp但是不捕获匹配的文本 | | | | (?=exp) | 匹配exp前面的位置 | \\b\\w+(?=ing) | 可以匹配I'm dancing中的danc | | (?<=exp) | 匹配exp后面的位置 | (?<=\\bdanc)\\w+\\b | 可以匹配I love dancing and reading中的第一个ing | diff --git a/Day01-15/15.图像和办公文档处理.md b/Day01-15/15.图像和办公文档处理.md index 765afa0..7ab5a80 100644 --- a/Day01-15/15.图像和办公文档处理.md +++ b/Day01-15/15.图像和办公文档处理.md @@ -110,13 +110,70 @@ Pillow中最为重要的是Image类,读取和处理图像都要通过这个类 ### 处理Excel电子表格 -Python的openpyxl模块让我们可以在Python程序中读取和修改Excel电子表格,当然实际工作中,我们可能会用LibreOffice Calc和OpenOffice Calc来处理Excel的电子表格文件,这就意味着openpyxl模块也能处理来自这些软件生成的电子表格。关于openpyxl的使用手册和使用文档可以查看它的[官方文档](https://openpyxl.readthedocs.io/en/stable/#)。 +Python的openpyxl模块让我们可以在Python程序中读取和修改Excel电子表格,由于微软从Office 2007开始使用了新的文件格式,这使得Office Excel和LibreOffice Calc、OpenOffice Calc是完全兼容的,这就意味着openpyxl模块也能处理来自这些软件生成的电子表格。 + +```Python +import datetime + +from openpyxl import Workbook + +wb = Workbook() +ws = wb.active + +ws['A1'] = 42 +ws.append([1, 2, 3]) +ws['A2'] = datetime.datetime.now() + +wb.save("sample.xlsx") +``` ### 处理Word文档 -利用python-docx模块,Pytho 可以创建和修改Word文档,当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档,LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。 +利用python-docx模块,Python可以创建和修改Word文档,当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档,LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。 +```Python +from docx import Document +from docx.shared import Inches -### 处理PDF文档 +document = Document() -PDF是Portable Document Format的缩写,使用.pdf作为文件扩展名。接下来我们就研究一下如何通过Python实现从PDF读取文本内容和从已有的文档生成新的PDF文件。 \ No newline at end of file +document.add_heading('Document Title', 0) + +p = document.add_paragraph('A plain paragraph having some ') +p.add_run('bold').bold = True +p.add_run(' and some ') +p.add_run('italic.').italic = True + +document.add_heading('Heading, level 1', level=1) +document.add_paragraph('Intense quote', style='Intense Quote') + +document.add_paragraph( + 'first item in unordered list', style='List Bullet' +) +document.add_paragraph( + 'first item in ordered list', style='List Number' +) + +document.add_picture('monty-truth.png', width=Inches(1.25)) + +records = ( + (3, '101', 'Spam'), + (7, '422', 'Eggs'), + (4, '631', 'Spam, spam, eggs, and spam') +) + +table = document.add_table(rows=1, cols=3) +hdr_cells = table.rows[0].cells +hdr_cells[0].text = 'Qty' +hdr_cells[1].text = 'Id' +hdr_cells[2].text = 'Desc' +for qty, id, desc in records: + row_cells = table.add_row().cells + row_cells[0].text = str(qty) + row_cells[1].text = id + row_cells[2].text = desc + +document.add_page_break() + +document.save('demo.docx') +``` diff --git a/Day01-15/code/Day11/mm.jpg b/Day01-15/code/Day11/mm.jpg index 882abf2..e3381b7 100644 Binary files a/Day01-15/code/Day11/mm.jpg and b/Day01-15/code/Day11/mm.jpg differ diff --git a/Day01-15/code/Day14/guido.jpg b/Day01-15/code/Day14/guido.jpg index 78f71ae..a8f217c 100644 Binary files a/Day01-15/code/Day14/guido.jpg and b/Day01-15/code/Day14/guido.jpg differ diff --git a/Day01-15/code/Day15/res/guido.jpg b/Day01-15/code/Day15/res/guido.jpg index 78f71ae..a8f217c 100644 Binary files a/Day01-15/code/Day15/res/guido.jpg and b/Day01-15/code/Day15/res/guido.jpg differ diff --git a/Day01-15/code/Day15/res/luohao.png b/Day01-15/code/Day15/res/luohao.png index 31593b5..a190074 100644 Binary files a/Day01-15/code/Day15/res/luohao.png and b/Day01-15/code/Day15/res/luohao.png differ diff --git a/Day01-15/res/TCP-IP-model.png b/Day01-15/res/TCP-IP-model.png index 777af47..1c641fc 100644 Binary files a/Day01-15/res/TCP-IP-model.png and b/Day01-15/res/TCP-IP-model.png differ diff --git a/Day01-15/res/after-browser.jpg b/Day01-15/res/after-browser.jpg index 7cc9520..fb6b27c 100644 Binary files a/Day01-15/res/after-browser.jpg and b/Day01-15/res/after-browser.jpg differ diff --git a/Day01-15/res/arpanet.png b/Day01-15/res/arpanet.png index 65d2dd3..3a1f632 100644 Binary files a/Day01-15/res/arpanet.png and b/Day01-15/res/arpanet.png differ diff --git a/Day01-15/res/ball-game.png b/Day01-15/res/ball-game.png index 37b9f89..a0b175b 100644 Binary files a/Day01-15/res/ball-game.png and b/Day01-15/res/ball-game.png differ diff --git a/Day01-15/res/ball.png b/Day01-15/res/ball.png index 0a63bdc..496e6b5 100644 Binary files a/Day01-15/res/ball.png and b/Day01-15/res/ball.png differ diff --git a/Day01-15/res/before-browser.jpg b/Day01-15/res/before-browser.jpg index f816144..89c3acf 100644 Binary files a/Day01-15/res/before-browser.jpg and b/Day01-15/res/before-browser.jpg differ diff --git a/Day01-15/res/browers.jpg b/Day01-15/res/browers.jpg index 0be1d4d..2802a23 100644 Binary files a/Day01-15/res/browers.jpg and b/Day01-15/res/browers.jpg differ diff --git a/Day01-15/res/browser-market-place.jpeg b/Day01-15/res/browser-market-place.jpeg index 196b0f4..cb71d38 100644 Binary files a/Day01-15/res/browser-market-place.jpeg and b/Day01-15/res/browser-market-place.jpeg differ diff --git a/Day01-15/res/fibonacci-blocks.png b/Day01-15/res/fibonacci-blocks.png index a638bf1..be4fc13 100644 Binary files a/Day01-15/res/fibonacci-blocks.png and b/Day01-15/res/fibonacci-blocks.png differ diff --git a/Day01-15/res/file-open-mode.png b/Day01-15/res/file-open-mode.png index 2d01ad4..dd6b927 100644 Binary files a/Day01-15/res/file-open-mode.png and b/Day01-15/res/file-open-mode.png differ diff --git a/Day01-15/res/formula_1.png b/Day01-15/res/formula_1.png index 5a0a7e2..ec5e551 100644 Binary files a/Day01-15/res/formula_1.png and b/Day01-15/res/formula_1.png differ diff --git a/Day01-15/res/formula_2.png b/Day01-15/res/formula_2.png index c21c2ae..954d921 100644 Binary files a/Day01-15/res/formula_2.png and b/Day01-15/res/formula_2.png differ diff --git a/Day01-15/res/formula_3.png b/Day01-15/res/formula_3.png index b9a84ed..716835f 100644 Binary files a/Day01-15/res/formula_3.png and b/Day01-15/res/formula_3.png differ diff --git a/Day01-15/res/formula_4.png b/Day01-15/res/formula_4.png index 692fb08..c87452f 100644 Binary files a/Day01-15/res/formula_4.png and b/Day01-15/res/formula_4.png differ diff --git a/Day01-15/res/formula_5.png b/Day01-15/res/formula_5.png index 28fad34..29e0a58 100644 Binary files a/Day01-15/res/formula_5.png and b/Day01-15/res/formula_5.png differ diff --git a/Day01-15/res/formula_6.png b/Day01-15/res/formula_6.png index 86df5da..41e0dfa 100644 Binary files a/Day01-15/res/formula_6.png and b/Day01-15/res/formula_6.png differ diff --git a/Day01-15/res/formula_7.png b/Day01-15/res/formula_7.png index 92cd76d..dfade18 100644 Binary files a/Day01-15/res/formula_7.png and b/Day01-15/res/formula_7.png differ diff --git a/Day01-15/res/formula_8.png b/Day01-15/res/formula_8.png index a37f92b..f3f2e29 100644 Binary files a/Day01-15/res/formula_8.png and b/Day01-15/res/formula_8.png differ diff --git a/Day01-15/res/how-data-is-processed.jpg b/Day01-15/res/how-data-is-processed.jpg index 4359bcd..b1f5486 100644 Binary files a/Day01-15/res/how-data-is-processed.jpg and b/Day01-15/res/how-data-is-processed.jpg differ diff --git a/Day01-15/res/image-crop.png b/Day01-15/res/image-crop.png index bb4a9bf..fa19b5b 100644 Binary files a/Day01-15/res/image-crop.png and b/Day01-15/res/image-crop.png differ diff --git a/Day01-15/res/image-filter.png b/Day01-15/res/image-filter.png index aac571c..ff512e5 100644 Binary files a/Day01-15/res/image-filter.png and b/Day01-15/res/image-filter.png differ diff --git a/Day01-15/res/image-paste.png b/Day01-15/res/image-paste.png index 6c5c39d..df25e85 100644 Binary files a/Day01-15/res/image-paste.png and b/Day01-15/res/image-paste.png differ diff --git a/Day01-15/res/image-putpixel.png b/Day01-15/res/image-putpixel.png index 54712b7..4a4a7a8 100644 Binary files a/Day01-15/res/image-putpixel.png and b/Day01-15/res/image-putpixel.png differ diff --git a/Day01-15/res/image-rotate.png b/Day01-15/res/image-rotate.png index 5db7459..84af30b 100644 Binary files a/Day01-15/res/image-rotate.png and b/Day01-15/res/image-rotate.png differ diff --git a/Day01-15/res/image-show.png b/Day01-15/res/image-show.png index 396cb5a..15723fb 100644 Binary files a/Day01-15/res/image-show.png and b/Day01-15/res/image-show.png differ diff --git a/Day01-15/res/image-thumbnail.png b/Day01-15/res/image-thumbnail.png index 91c623f..a6d5239 100644 Binary files a/Day01-15/res/image-thumbnail.png and b/Day01-15/res/image-thumbnail.png differ diff --git a/Day01-15/res/image-transpose.png b/Day01-15/res/image-transpose.png index 685a280..43a8007 100644 Binary files a/Day01-15/res/image-transpose.png and b/Day01-15/res/image-transpose.png differ diff --git a/Day01-15/res/ipython-timeit.png b/Day01-15/res/ipython-timeit.png index 5b52382..9125921 100644 Binary files a/Day01-15/res/ipython-timeit.png and b/Day01-15/res/ipython-timeit.png differ diff --git a/Day01-15/res/macos-monitor.png b/Day01-15/res/macos-monitor.png index 3d1b88b..cac5138 100644 Binary files a/Day01-15/res/macos-monitor.png and b/Day01-15/res/macos-monitor.png differ diff --git a/Day01-15/res/object-feature.png b/Day01-15/res/object-feature.png index 62c6057..538fa4d 100644 Binary files a/Day01-15/res/object-feature.png and b/Day01-15/res/object-feature.png differ diff --git a/Day01-15/res/oop-zhihu.png b/Day01-15/res/oop-zhihu.png index c473984..8aa05c6 100644 Binary files a/Day01-15/res/oop-zhihu.png and b/Day01-15/res/oop-zhihu.png differ diff --git a/Day01-15/res/osi_rm.gif b/Day01-15/res/osi_rm.gif index 876960d..9228af5 100644 Binary files a/Day01-15/res/osi_rm.gif and b/Day01-15/res/osi_rm.gif differ diff --git a/Day01-15/res/osimodel.png b/Day01-15/res/osimodel.png index f0361c9..9c13968 100644 Binary files a/Day01-15/res/osimodel.png and b/Day01-15/res/osimodel.png differ diff --git a/Day01-15/res/python-idle.png b/Day01-15/res/python-idle.png index 1e90598..e55248f 100644 Binary files a/Day01-15/res/python-idle.png and b/Day01-15/res/python-idle.png differ diff --git a/Day01-15/res/python-ipython.png b/Day01-15/res/python-ipython.png index c3a9054..35d34a7 100644 Binary files a/Day01-15/res/python-ipython.png and b/Day01-15/res/python-ipython.png differ diff --git a/Day01-15/res/python-jupyter-1.png b/Day01-15/res/python-jupyter-1.png index 58cedc5..cad28e2 100644 Binary files a/Day01-15/res/python-jupyter-1.png and b/Day01-15/res/python-jupyter-1.png differ diff --git a/Day01-15/res/python-jupyter-2.png b/Day01-15/res/python-jupyter-2.png index 2724988..70102b0 100644 Binary files a/Day01-15/res/python-jupyter-2.png and b/Day01-15/res/python-jupyter-2.png differ diff --git a/Day01-15/res/python-pycharm.png b/Day01-15/res/python-pycharm.png index ffae8c3..57f2da5 100644 Binary files a/Day01-15/res/python-pycharm.png and b/Day01-15/res/python-pycharm.png differ diff --git a/Day01-15/res/python-set.png b/Day01-15/res/python-set.png index 2110598..0d59ce1 100644 Binary files a/Day01-15/res/python-set.png and b/Day01-15/res/python-set.png differ diff --git a/Day01-15/res/python-sublime.png b/Day01-15/res/python-sublime.png index c786d13..ce9590d 100644 Binary files a/Day01-15/res/python-sublime.png and b/Day01-15/res/python-sublime.png differ diff --git a/Day01-15/res/tcpipprotocols.png b/Day01-15/res/tcpipprotocols.png index 4acf216..bb62ed2 100644 Binary files a/Day01-15/res/tcpipprotocols.png and b/Day01-15/res/tcpipprotocols.png differ diff --git a/Day01-15/res/tel-start-number.png b/Day01-15/res/tel-start-number.png index b1be7a9..827522c 100644 Binary files a/Day01-15/res/tel-start-number.png and b/Day01-15/res/tel-start-number.png differ diff --git a/Day01-15/res/telnet.png b/Day01-15/res/telnet.png index 20c8653..1aa4d4d 100644 Binary files a/Day01-15/res/telnet.png and b/Day01-15/res/telnet.png differ diff --git a/Day01-15/res/uml-components.png b/Day01-15/res/uml-components.png index 0394cd7..00598b8 100644 Binary files a/Day01-15/res/uml-components.png and b/Day01-15/res/uml-components.png differ diff --git a/Day01-15/res/uml-example.png b/Day01-15/res/uml-example.png index 14e8e9c..1638fe7 100644 Binary files a/Day01-15/res/uml-example.png and b/Day01-15/res/uml-example.png differ diff --git a/Day16-20/16-20.Python语言进阶.md b/Day16-20/16-20.Python语言进阶.md index eabc351..abdf665 100644 --- a/Day16-20/16-20.Python语言进阶.md +++ b/Day16-20/16-20.Python语言进阶.md @@ -1,1352 +1,1397 @@ ## Python语言进阶 -1. 数据结构和算法 - - - 算法:解决问题的方法和步骤 - - - 评价算法的好坏:渐近时间复杂度和渐近空间复杂度。 - - - 渐近时间复杂度的大O标记: - - - 常量时间复杂度 - 布隆过滤器 / 哈希存储 - - - 对数时间复杂度 - 折半查找(二分查找) - - - 线性时间复杂度 - 顺序查找 / 桶排序 - - - 对数线性时间复杂度 - 高级排序算法(归并排序、快速排序) - - - 平方时间复杂度 - 简单排序算法(选择排序、插入排序、冒泡排序) - - - 立方时间复杂度 - Floyd算法 / 矩阵乘法运算 - - - 几何级数时间复杂度 - 汉诺塔 - - - 阶乘时间复杂度 - 旅行经销商问题 - NP - - ![](./res/algorithm_complexity_1.png) - - ![](./res/algorithm_complexity_2.png) - - - 排序算法(选择、冒泡和归并)和查找算法(顺序和折半) - - ```Python - def select_sort(origin_items, comp=lambda x, y: x < y): - """简单选择排序""" - items = origin_items[:] - for i in range(len(items) - 1): - min_index = i - for j in range(i + 1, len(items)): - if comp(items[j], items[min_index]): - min_index = j - items[i], items[min_index] = items[min_index], items[i] - return items - ``` - - ```Python - def bubble_sort(origin_items, comp=lambda x, y: x > y): - """高质量冒泡排序(搅拌排序)""" - items = origin_items[:] - for i in range(len(items) - 1): - swapped = False - for j in range(i, len(items) - 1 - i): - if comp(items[j], items[j + 1]): - items[j], items[j + 1] = items[j + 1], items[j] - swapped = True - if swapped: - swapped = False - for j in range(len(items) - 2 - i, i, -1): - if comp(items[j - 1], items[j]): - items[j], items[j - 1] = items[j - 1], items[j] - swapped = True - if not swapped: - break - return items - ``` - - ```Python - def merge_sort(items, comp=lambda x, y: x <= y): - """归并排序(分治法)""" - if len(items) < 2: - return items[:] - mid = len(items) // 2 - left = merge_sort(items[:mid], comp) - right = merge_sort(items[mid:], comp) - return merge(left, right, comp) - - - def merge(items1, items2, comp): - """合并(将两个有序的列表合并成一个有序的列表)""" - items = [] - index1, index2 = 0, 0 - while index1 < len(items1) and index2 < len(items2): - if comp(items1[index1], items2[index2]): - items.append(items1[index1]) - index1 += 1 - else: - items.append(items2[index2]) - index2 += 1 - items += items1[index1:] - items += items2[index2:] - return items - ``` - - ```Python - def seq_search(items, key): - """顺序查找""" - for index, item in enumerate(items): - if item == key: - return index - return -1 - ``` - - ```Python - def bin_search(items, key): - """折半查找""" - start, end = 0, len(items) - 1 - while start <= end: - mid = (start + end) // 2 - if key > items[mid]: - start = mid + 1 - elif key < items[mid]: - end = mid - 1 - else: - return mid - return -1 - ``` - - - 使用生成式(推导式)语法 - - ```Python - prices = { - 'AAPL': 191.88, - 'GOOG': 1186.96, - 'IBM': 149.24, - 'ORCL': 48.44, - 'ACN': 166.89, - 'FB': 208.09, - 'SYMC': 21.29 - } - # 用股票价格大于100元的股票构造一个新的字典 - prices2 = {key: value for key, value in prices.items() if value > 100} - print(prices2) - ``` - - > 说明:生成式(推导式)可以用来生成列表、集合和字典。 - - - 嵌套的列表 - - ```Python - names = ['关羽', '张飞', '赵云', '马超', '黄忠'] - courses = ['语文', '数学', '英语'] - # 录入五个学生三门课程的成绩 - # 错误 - 参考http://pythontutor.com/visualize.html#mode=edit - # scores = [[None] * len(courses)] * len(names) - scores = [[None] * len(courses) for _ in range(len(names))] - for row, name in enumerate(names): - for col, course in enumerate(courses): - scores[row][col] = float(input(f'请输入{name}的{course}成绩: ')) - print(scores) - ``` - - [Python Tutor](http://pythontutor.com/) - VISUALIZE CODE AND GET LIVE HELP - - - heapq、itertools等的用法 - ```Python - """ - 从列表中找出最大的或最小的N个元素 - 堆结构(大根堆/小根堆) - """ - import heapq - - list1 = [34, 25, 12, 99, 87, 63, 58, 78, 88, 92] - list2 = [ - {'name': 'IBM', 'shares': 100, 'price': 91.1}, - {'name': 'AAPL', 'shares': 50, 'price': 543.22}, - {'name': 'FB', 'shares': 200, 'price': 21.09}, - {'name': 'HPQ', 'shares': 35, 'price': 31.75}, - {'name': 'YHOO', 'shares': 45, 'price': 16.35}, - {'name': 'ACME', 'shares': 75, 'price': 115.65} - ] - print(heapq.nlargest(3, list1)) - print(heapq.nsmallest(3, list1)) - print(heapq.nlargest(2, list2, key=lambda x: x['price'])) - print(heapq.nlargest(2, list2, key=lambda x: x['shares'])) - ``` - - ```Python - """ - 迭代工具 - 排列 / 组合 / 笛卡尔积 - """ - import itertools - - itertools.permutations('ABCD') - itertools.combinations('ABCDE', 3) - itertools.product('ABCD', '123') - ``` - - - collections模块下的工具类 - - ```Python - """ - 找出序列中出现次数最多的元素 - """ - from collections import Counter - - words = [ - 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', - 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', - 'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes', - 'look', 'into', 'my', 'eyes', "you're", 'under' - ] - counter = Counter(words) - print(counter.most_common(3)) - ``` - - - 常用算法: - - - 穷举法 - 又称为暴力破解法,对所有的可能性进行验证,直到找到正确答案。 - - 贪婪法 - 在对问题求解时,总是做出在当前看来 - - 最好的选择,不追求最优解,快速找到满意解。 - - 分治法 - 把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题,直到可以直接求解的程度,最后将子问题的解进行合并得到原问题的解。 - - 回溯法 - 回溯法又称为试探法,按选优条件向前搜索,当搜索到某一步发现原先选择并不优或达不到目标时,就退回一步重新选择。 - - 动态规划 - 基本思想也是将待求解问题分解成若干个子问题,先求解并保存这些子问题的解,避免产生大量的重复运算。 - - 穷举法例子:百钱百鸡和五人分鱼。 - - ```Python - # 公鸡5元一只 母鸡3元一只 小鸡1元三只 - # 用100元买100只鸡 问公鸡/母鸡/小鸡各多少只 - for x in range(20): - for y in range(33): - z = 100 - x - y - if 5 * x + 3 * y + z // 3 == 100 and z % 3 == 0: - print(x, y, z) - - # A、B、C、D、E五人在某天夜里合伙捕鱼 最后疲惫不堪各自睡觉 - # 第二天A第一个醒来 他将鱼分为5份 扔掉多余的1条 拿走自己的一份 - # B第二个醒来 也将鱼分为5份 扔掉多余的1条 拿走自己的一份 - # 然后C、D、E依次醒来也按同样的方式分鱼 问他们至少捕了多少条鱼 - fish = 6 - while True: - total = fish - enough = True - for _ in range(5): - if (total - 1) % 5 == 0: - total = (total - 1) // 5 * 4 - else: - enough = False - break - if enough: - print(fish) - break - fish += 5 - ``` - - 贪婪法例子:假设小偷有一个背包,最多能装20公斤赃物,他闯入一户人家,发现如下表所示的物品。很显然,他不能把所有物品都装进背包,所以必须确定拿走哪些物品,留下哪些物品。 - - | 名称 | 价格(美元) | 重量(kg) | - | :----: | :----------: | :--------: | - | 电脑 | 200 | 20 | - | 收音机 | 20 | 4 | - | 钟 | 175 | 10 | - | 花瓶 | 50 | 2 | - | 书 | 10 | 1 | - | 油画 | 90 | 9 | - - ```Python - """ - 贪婪法:在对问题求解时,总是做出在当前看来是最好的选择,不追求最优解,快速找到满意解。 - 输入: - 20 6 - 电脑 200 20 - 收音机 20 4 - 钟 175 10 - 花瓶 50 2 - 书 10 1 - 油画 90 9 - """ - class Thing(object): - """物品""" - - def __init__(self, name, price, weight): - self.name = name - self.price = price - self.weight = weight - - @property - def value(self): - """价格重量比""" - return self.price / self.weight - - - def input_thing(): - """输入物品信息""" - name_str, price_str, weight_str = input().split() - return name_str, int(price_str), int(weight_str) - - - def main(): - """主函数""" - max_weight, num_of_things = map(int, input().split()) - all_things = [] - for _ in range(num_of_things): - all_things.append(Thing(*input_thing())) - all_things.sort(key=lambda x: x.value, reverse=True) - total_weight = 0 - total_price = 0 - for thing in all_things: - if total_weight + thing.weight <= max_weight: - print(f'小偷拿走了{thing.name}') - total_weight += thing.weight - total_price += thing.price - print(f'总价值: {total_price}美元') - - - if __name__ == '__main__': - main() - ``` - - 分治法例子:[快速排序](https://zh.wikipedia.org/zh/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F)。 - - ```Python - """ - 快速排序 - 选择枢轴对元素进行划分,左边都比枢轴小右边都比枢轴大 - """ - def quick_sort(origin_items, comp=lambda x, y: x <= y): - items = origin_items[:] - _quick_sort(items, 0, len(items) - 1, comp) - return items - - - def _quick_sort(items, start, end, comp): - if start < end: - pos = _partition(items, start, end, comp) - _quick_sort(items, start, pos - 1, comp) - _quick_sort(items, pos + 1, end, comp) - - - def _partition(items, start, end, comp): - pivot = items[end] - i = start - 1 - for j in range(start, end): - if comp(items[j], pivot): - i += 1 - items[i], items[j] = items[j], items[i] - items[i + 1], items[end] = items[end], items[i + 1] - return i + 1 - ``` - - 回溯法例子:[骑士巡逻](https://zh.wikipedia.org/zh/%E9%AA%91%E5%A3%AB%E5%B7%A1%E9%80%BB)。 - - ```Python - """ - 递归回溯法:叫称为试探法,按选优条件向前搜索,当搜索到某一步,发现原先选择并不优或达不到目标时,就退回一步重新选择,比较经典的问题包括骑士巡逻、八皇后和迷宫寻路等。 - """ - import sys - import time - - SIZE = 5 - total = 0 - - - def print_board(board): - for row in board: - for col in row: - print(str(col).center(4), end='') - print() - - - def patrol(board, row, col, step=1): - if row >= 0 and row < SIZE and \ - col >= 0 and col < SIZE and \ - board[row][col] == 0: - board[row][col] = step - if step == SIZE * SIZE: - global total - total += 1 - print(f'第{total}种走法: ') - print_board(board) - patrol(board, row - 2, col - 1, step + 1) - patrol(board, row - 1, col - 2, step + 1) - patrol(board, row + 1, col - 2, step + 1) - patrol(board, row + 2, col - 1, step + 1) - patrol(board, row + 2, col + 1, step + 1) - patrol(board, row + 1, col + 2, step + 1) - patrol(board, row - 1, col + 2, step + 1) - patrol(board, row - 2, col + 1, step + 1) - board[row][col] = 0 - - - def main(): - board = [[0] * SIZE for _ in range(SIZE)] - patrol(board, SIZE - 1, SIZE - 1) - - - if __name__ == '__main__': - main() - ``` - - 动态规划例子1:[斐波拉切数列]()。(不使用动态规划将会是几何级数复杂度) - - ```Python - """ - 动态规划 - 适用于有重叠子问题和最优子结构性质的问题 - 使用动态规划方法所耗时间往往远少于朴素解法(用空间换取时间) - """ - def fib(num, temp={}): - """用递归计算Fibonacci数""" - if num in (1, 2): - return 1 - try: - return temp[num] - except KeyError: - temp[num] = fib(num - 1) + fib(num - 2) - return temp[num] - ``` - - 动态规划例子2:子列表元素之和的最大值。(使用动态规划可以避免二重循环) - - > 说明:子列表指的是列表中索引(下标)连续的元素构成的列表;列表中的元素是int类型,可能包含正整数、0、负整数;程序输入列表中的元素,输出子列表元素求和的最大值,例如: - > - > 输入:1 -2 3 5 -3 2 - > - > 输出:8 - > - > 输入:0 -2 3 5 -1 2 - > - > 输出:9 - > - > 输入:-9 -2 -3 -5 -3 - > - > 输出:-2 - - ```Python - def main(): - items = list(map(int, input().split())) - size = len(items) - overall, partial = {}, {} - overall[size - 1] = partial[size - 1] = items[size - 1] - for i in range(size - 2, -1, -1): - partial[i] = max(items[i], partial[i + 1] + items[i]) - overall[i] = max(partial[i], overall[i + 1]) - print(overall[0]) - - - if __name__ == '__main__': - main() - ``` - -2. 函数的使用方式 - - - 将函数视为“一等公民” - - - 函数可以赋值给变量 - - 函数可以作为函数的参数 - - 函数可以作为函数的返回值 - - - 高阶函数的用法(`filter`、`map`以及它们的替代品) - - ```Python - items1 = list(map(lambda x: x ** 2, filter(lambda x: x % 2, range(1, 10)))) - items2 = [x ** 2 for x in range(1, 10) if x % 2] - ``` - - - 位置参数、可变参数、关键字参数、命名关键字参数 - - - 参数的元信息(代码可读性问题) - - - 匿名函数和内联函数的用法(`lambda`函数) - - - 闭包和作用域问题 - - - Python搜索变量的LEGB顺序(Local --> Embedded --> Global --> Built-in) - - - `global`和`nonlocal`关键字的作用 - - `global`:声明或定义全局变量(要么直接使用现有的全局作用域的变量,要么定义一个变量放到全局作用域)。 - - `nonlocal`:声明使用嵌套作用域的变量(嵌套作用域必须存在该变量,否则报错)。 - - - 装饰器函数(使用装饰器和取消装饰器) - - 例子:输出函数执行时间的装饰器。 - - ```Python - def record_time(func): - """自定义装饰函数的装饰器""" - - @wraps(func) - def wrapper(*args, **kwargs): - start = time() - result = func(*args, **kwargs) - print(f'{func.__name__}: {time() - start}秒') - return result - - return wrapper - ``` - - 如果装饰器不希望跟`print`函数耦合,可以编写带参数的装饰器。 - - ```Python - from functools import wraps - from time import time - - - def record(output): - """自定义带参数的装饰器""" - - def decorate(func): - - @wraps(func) - def wrapper(*args, **kwargs): - start = time() - result = func(*args, **kwargs) - output(func.__name__, time() - start) - return result - - return wrapper - - return decorate - ``` - - ```Python - from functools import wraps - from time import time - - - class Record(): - """自定义装饰器类(通过__call__魔术方法使得对象可以当成函数调用)""" - - def __init__(self, output): - self.output = output - - def __call__(self, func): - - @wraps(func) - def wrapper(*args, **kwargs): - start = time() - result = func(*args, **kwargs) - self.output(func.__name__, time() - start) - return result - - return wrapper - ``` - - > 说明:由于对带装饰功能的函数添加了@wraps装饰器,可以通过`func.__wrapped__`方式获得被装饰之前的函数或类来取消装饰器的作用。 - - 例子:用装饰器来实现单例模式。 - - ```Python - from functools import wraps - - - def singleton(cls): - """装饰类的装饰器""" - instances = {} - - @wraps(cls) - def wrapper(*args, **kwargs): - if cls not in instances: - instances[cls] = cls(*args, **kwargs) - return instances[cls] - - return wrapper - - - @singleton - class President(): - """总统(单例类)""" - pass - ``` - - > 说明:上面的代码中用到了闭包(closure),不知道你是否已经意识到了。还没有一个小问题就是,上面的代码并没有实现线程安全的单例,如果要实现线程安全的单例应该怎么做呢? - - ```Python - from functools import wraps - from threading import Lock - - - def singleton(cls): - """线程安全的单例装饰器""" - instances = {} - locker = Lock() - - @wraps(cls) - def wrapper(*args, **kwargs): - if cls not in instances: - with locker: - if cls not in instances: - instances[cls] = cls(*args, **kwargs) - return instances[cls] - - return wrapper - ``` - -3. 面向对象相关知识 - - - 三大支柱:封装、继承、多态 - - 例子:工资结算系统。 - - ```Python - """ - 月薪结算系统 - 部门经理每月15000 程序员每小时200 销售员1800底薪加销售额5%提成 - """ - from abc import ABCMeta, abstractmethod - - - class Employee(metaclass=ABCMeta): - """员工(抽象类)""" - - def __init__(self, name): - self.name = name - - @abstractmethod - def get_salary(self): - """结算月薪(抽象方法)""" - pass - - - class Manager(Employee): - """部门经理""" - - def get_salary(self): - return 15000.0 - - - class Programmer(Employee): - """程序员""" - - def __init__(self, name, working_hour=0): - self.working_hour = working_hour - super().__init__(name) - - def get_salary(self): - return 200.0 * self.working_hour - - - class Salesman(Employee): - """销售员""" - - def __init__(self, name, sales=0.0): - self.sales = sales - super().__init__(name) - - def get_salary(self): - return 1800.0 + self.sales * 0.05 - - - class EmployeeFactory(): - """创建员工的工厂(工厂模式 - 通过工厂实现对象使用者和对象之间的解耦合)""" - - @staticmethod - def create(emp_type, *args, **kwargs): - """创建员工""" - emp_type = emp_type.upper() - emp = None - if emp_type == 'M': - emp = Manager(*args, **kwargs) - elif emp_type == 'P': - emp = Programmer(*args, **kwargs) - elif emp_type == 'S': - emp = Salesman(*args, **kwargs) - return emp - - - def main(): - """主函数""" - emps = [ - EmployeeFactory.create('M', '曹操'), - EmployeeFactory.create('P', '荀彧', 120), - EmployeeFactory.create('P', '郭嘉', 85), - EmployeeFactory.create('S', '典韦', 123000), - ] - for emp in emps: - print('%s: %.2f元' % (emp.name, emp.get_salary())) - - - if __name__ == '__main__': - main() - ``` - - - 类与类之间的关系 - - - is-a关系:继承 - - has-a关系:关联 / 聚合 / 合成 - - use-a关系:依赖 - - 例子:扑克游戏。 - - ```Python - """ - 经验:符号常量总是优于字面常量,枚举类型是定义符号常量的最佳选择 - """ - from enum import Enum, unique - - import random - - - @unique - class Suite(Enum): - """花色""" - - SPADE, HEART, CLUB, DIAMOND = range(4) - - def __lt__(self, other): - return self.value < other.value - - - class Card(): - """牌""" - - def __init__(self, suite, face): - """初始化方法""" - self.suite = suite - self.face = face - - def show(self): - """显示牌面""" - suites = ['♠️', '♥️', '♣️', '♦️'] - faces = ['', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] - return f'{suites[self.suite.value]} {faces[self.face]}' - - def __str__(self): - return self.show() - - def __repr__(self): - return self.show() - - - class Poker(): - """扑克""" - - def __init__(self): - self.index = 0 - self.cards = [Card(suite, face) - for suite in Suite - for face in range(1, 14)] - - def shuffle(self): - """洗牌(随机乱序)""" - random.shuffle(self.cards) - self.index = 0 - - def deal(self): - """发牌""" - card = self.cards[self.index] - self.index += 1 - return card - - @property - def has_more(self): - return self.index < len(self.cards) - - - class Player(): - """玩家""" - - def __init__(self, name): - self.name = name - self.cards = [] - - def get_one(self, card): - """摸一张牌""" - self.cards.append(card) - - def sort(self, comp=lambda card: (card.suite, card.face)): - """整理手上的牌""" - self.cards.sort(key=comp) - - - def main(): - """主函数""" - poker = Poker() - poker.shuffle() - players = [Player('东邪'), Player('西毒'), Player('南帝'), Player('北丐')] - while poker.has_more: - for player in players: - player.get_one(poker.deal()) - for player in players: - player.sort() - print(player.name, end=': ') - print(player.cards) - - - if __name__ == '__main__': - main() - ``` - - > 说明:上面的代码中使用了Emoji字符来表示扑克牌的四种花色,在某些不支持Emoji字符的系统上可能无法显示。 - - - 对象的复制(深复制/深拷贝/深度克隆和浅复制/浅拷贝/影子克隆) - - - 垃圾回收、循环引用和弱引用 - - Python使用了自动化内存管理,这种管理机制以**引用计数**为基础,同时也引入了**标记-清除**和**分代收集**两种机制为辅的策略。 - - ```C - typedef struct_object { - /* 引用计数 */ - int ob_refcnt; - /* 对象指针 */ - struct_typeobject *ob_type; - } PyObject; - ``` - - ```C - /* 增加引用计数的宏定义 */ - #define Py_INCREF(op) ((op)->ob_refcnt++) - /* 减少引用计数的宏定义 */ - #define Py_DECREF(op) \ //减少计数 - if (--(op)->ob_refcnt != 0) \ - ; \ - else \ - __Py_Dealloc((PyObject *)(op)) - ``` - - 导致引用计数+1的情况: - - - 对象被创建,例如`a = 23` - - 对象被引用,例如`b = a` - - 对象被作为参数,传入到一个函数中,例如`f(a)` - - 对象作为一个元素,存储在容器中,例如`list1 = [a, a]` - - 导致引用计数-1的情况: - - - 对象的别名被显式销毁,例如`del a` - - 对象的别名被赋予新的对象,例如`a = 24` - - 一个对象离开它的作用域,例如f函数执行完毕时,f函数中的局部变量(全局变量不会) - - 对象所在的容器被销毁,或从容器中删除对象 - - 引用计数可能会导致循环引用问题,而循环引用会导致内存泄露,如下面的代码所示。为了解决这个问题,Python中引入了“标记-清除”和“分代收集”。在创建一个对象的时候,对象被放在第一代中,如果在第一代的垃圾检查中对象存活了下来,该对象就会被放到第二代中,同理在第二代的垃圾检查中对象存活下来,该对象就会被放到第三代中。 - - ```Python - # 循环引用会导致内存泄露 - Python除了引用技术还引入了标记清理和分代回收 - # 在Python 3.6以前如果重写__del__魔术方法会导致循环引用处理失效 - # 如果不想造成循环引用可以使用弱引用 - list1 = [] - list2 = [] - list1.append(list2) - list2.append(list1) - ``` - - 以下情况会导致垃圾回收: - - - 调用`gc.collect()` - - gc模块的计数器达到阀值 - - 程序退出 - - 如果循环引用中两个对象都定义了`__del__`方法,gc模块不会销毁这些不可达对象,因为gc模块不知道应该先调用哪个对象的`__del__`方法,这个问题在Python 3.6中得到了解决。 - - 也可以通过`weakref`模块构造弱引用的方式来解决循环引用的问题。 - - - 魔法属性和方法(请参考《Python魔法方法指南》) - - 有几个小问题请大家思考: - - - 自定义的对象能不能使用运算符做运算? - - 自定义的对象能不能放到set中?能去重吗? - - 自定义的对象能不能作为dict的键? - - 自定义的对象能不能使用上下文语法? - - - 混入(Mixin) - - 例子:自定义字典限制只有在指定的key不存在时才能在字典中设置键值对。 - - ```Python - class SetOnceMappingMixin(): - """自定义混入类""" - __slots__ = () - - def __setitem__(self, key, value): - if key in self: - raise KeyError(str(key) + ' already set') - return super().__setitem__(key, value) - - - class SetOnceDict(SetOnceMappingMixin, dict): - """自定义字典""" - pass - - - my_dict= SetOnceDict() - try: - my_dict['username'] = 'jackfrued' - my_dict['username'] = 'hellokitty' - except KeyError: - pass - print(my_dict) - ``` - - - 元编程和元类 - - 例子:用元类实现单例模式。 - - ```Python - import threading - - - class SingletonMeta(type): - """自定义元类""" - - def __init__(cls, *args, **kwargs): - cls.__instance = None - cls.__lock = threading.Lock() - super().__init__(*args, **kwargs) - - def __call__(cls, *args, **kwargs): - if cls.__instance is None: - with cls.__lock: - if cls.__instance is None: - cls.__instance = super().__call__(*args, **kwargs) - return cls.__instance - - - class President(metaclass=SingletonMeta): - """总统(单例类)""" - pass - ``` - - - 面向对象设计原则 - - - 单一职责原则 (**S**RP)- 一个类只做该做的事情(类的设计要高内聚) - - 开闭原则 (**O**CP)- 软件实体应该对扩展开发对修改关闭 - - 依赖倒转原则(DIP)- 面向抽象编程(在弱类型语言中已经被弱化) - - 里氏替换原则(**L**SP) - 任何时候可以用子类对象替换掉父类对象 - - 接口隔离原则(**I**SP)- 接口要小而专不要大而全(Python中没有接口的概念) - - 合成聚合复用原则(CARP) - 优先使用强关联关系而不是继承关系复用代码 - - 最少知识原则(迪米特法则,Lo**D**)- 不要给没有必然联系的对象发消息 - - > 说明:上面加粗的字母放在一起称为面向对象的**SOLID**原则。 - - - GoF设计模式 - - - 创建型模式:单例、工厂、建造者、原型 - - 结构型模式:适配器、门面(外观)、代理 - - 行为型模式:迭代器、观察者、状态、策略 - - 例子:可插拔的哈希算法。 - - ```Python - class StreamHasher(): - """哈希摘要生成器(策略模式)""" - - def __init__(self, alg='md5', size=4096): - self.size = size - alg = alg.lower() - self.hasher = getattr(__import__('hashlib'), alg.lower())() - - def __call__(self, stream): - return self.to_digest(stream) - - def to_digest(self, stream): - """生成十六进制形式的摘要""" - for buf in iter(lambda: stream.read(self.size), b''): - self.hasher.update(buf) - return self.hasher.hexdigest() - - def main(): - """主函数""" - hasher1 = StreamHasher() - with open('Python-3.7.1.tgz', 'rb') as stream: - print(hasher1.to_digest(stream)) - hasher2 = StreamHasher('sha1') - with open('Python-3.7.1.tgz', 'rb') as stream: - print(hasher2(stream)) - - - if __name__ == '__main__': - main() - ``` - -4. 迭代器和生成器 - - - 和迭代器相关的魔术方法(`__iter__`和`__next__`) - - - 两种创建生成器的方式(生成器表达式和`yield`关键字) - - ```Python - def fib(num): - """生成器""" - a, b = 0, 1 - for _ in range(num): - a, b = b, a + b - yield a - - - class Fib(object): - """迭代器""" - - def __init__(self, num): - self.num = num - self.a, self.b = 0, 1 - self.idx = 0 - - def __iter__(self): - return self - - def __next__(self): - if self.idx < self.num: - self.a, self.b = self.b, self.a + self.b - self.idx += 1 - return self.a - raise StopIteration() - ``` - -5. 并发编程 - - Python中实现并发编程的三种方案:多线程、多进程和异步I/O。并发编程的好处在于可以提升程序的执行效率以及改善用户体验;坏处在于并发的程序不容易开发和调试,同时对其他程序来说它并不友好。 - - - 多线程:Python中提供了Thread类并辅以Lock、Condition、Event、Semaphore和Barrier。Python中有GIL来防止多个线程同时执行本地字节码,这个锁对于CPython是必须的,因为CPython的内存管理并不是线程安全的,因为GIL的存在多线程并不能发挥CPU的多核特性。 - - ```Python - """ - 面试题:进程和线程的区别和联系? - 进程 - 操作系统分配内存的基本单位 - 一个进程可以包含一个或多个线程 - 线程 - 操作系统分配CPU的基本单位 - 并发编程(concurrent programming) - 1. 提升执行性能 - 让程序中没有因果关系的部分可以并发的执行 - 2. 改善用户体验 - 让耗时间的操作不会造成程序的假死 - """ - import glob - import os - import threading - - from PIL import Image - - PREFIX = 'thumbnails' - - - def generate_thumbnail(infile, size, format='PNG'): - """生成指定图片文件的缩略图""" - file, ext = os.path.splitext(infile) - file = file[file.rfind('/') + 1:] - outfile = f'{PREFIX}/{file}_{size[0]}_{size[1]}.{ext}' - img = Image.open(infile) - img.thumbnail(size, Image.ANTIALIAS) - img.save(outfile, format) - - - def main(): - """主函数""" - if not os.path.exists(PREFIX): - os.mkdir(PREFIX) - for infile in glob.glob('images/*.png'): - for size in (32, 64, 128): - # 创建并启动线程 - threading.Thread( - target=generate_thumbnail, - args=(infile, (size, size)) - ).start() - - - if __name__ == '__main__': - main() - ``` - - 多个线程竞争资源的情况 - - ```Python - """ - 多线程程序如果没有竞争资源处理起来通常也比较简单 - 当多个线程竞争临界资源的时候如果缺乏必要的保护措施就会导致数据错乱 - 说明:临界资源就是被多个线程竞争的资源 - """ - import time - import threading - - from concurrent.futures import ThreadPoolExecutor - - - class Account(object): - """银行账户""" - - def __init__(self): - self.balance = 0.0 - self.lock = threading.Lock() - - def deposit(self, money): - # 通过锁保护临界资源 - with self.lock: - new_balance = self.balance + money - time.sleep(0.001) - self.balance = new_balance - - - class AddMoneyThread(threading.Thread): - """自定义线程类""" - - def __init__(self, account, money): - self.account = account - self.money = money - # 自定义线程的初始化方法中必须调用父类的初始化方法 - super().__init__() - - def run(self): - # 线程启动之后要执行的操作 - self.account.deposit(self.money) - - def main(): - """主函数""" - account = Account() - # 创建线程池 - pool = ThreadPoolExecutor(max_workers=10) - futures = [] - for _ in range(100): - # 创建线程的第1种方式 - # threading.Thread( - # target=account.deposit, args=(1, ) - # ).start() - # 创建线程的第2种方式 - # AddMoneyThread(account, 1).start() - # 创建线程的第3种方式 - # 调用线程池中的线程来执行特定的任务 - future = pool.submit(account.deposit, 1) - futures.append(future) - # 关闭线程池 - pool.shutdown() - for future in futures: - future.result() - print(account.balance) - - - if __name__ == '__main__': - main() - ``` - - 修改上面的程序,启动5个线程向账户中存钱,5个线程从账户中取钱,取钱时如果余额不足就暂停线程进行等待。为了达到上述目标,需要对存钱和取钱的线程进行调度,在余额不足时取钱的线程暂停并释放锁,而存钱的线程将钱存入后要通知取钱的线程,使其从暂停状态被唤醒。可以使用`threading`模块的Condition来实现线程调度,该对象也是基于锁来创建的,代码如下所示: - - ```Python - """ - 多个线程竞争一个资源 - 保护临界资源 - 锁(Lock/RLock) - 多个线程竞争多个资源(线程数>资源数) - 信号量(Semaphore) - 多个线程的调度 - 暂停线程执行/唤醒等待中的线程 - Condition - """ - from concurrent.futures import ThreadPoolExecutor - from random import randint - from time import sleep - - import threading - - - class Account(): - """银行账户""" - - def __init__(self, balance=0): - self.balance = balance - lock = threading.Lock() - self.condition = threading.Condition(lock) - - def withdraw(self, money): - """取钱""" - with self.condition: - while money > self.balance: - self.condition.wait() - new_balance = self.balance - money - sleep(0.001) - self.balance = new_balance - - def deposit(self, money): - """存钱""" - with self.condition: - new_balance = self.balance + money - sleep(0.001) - self.balance = new_balance - self.condition.notify_all() - - - def add_money(account): - while True: - money = randint(5, 10) - account.deposit(money) - print(threading.current_thread().name, - ':', money, '====>', account.balance) - sleep(0.5) - - - def sub_money(account): - while True: - money = randint(10, 30) - account.withdraw(money) - print(threading.current_thread().name, - ':', money, '<====', account.balance) - sleep(1) - - - def main(): - account = Account() - with ThreadPoolExecutor(max_workers=10) as pool: - for _ in range(5): - pool.submit(add_money, account) - pool.submit(sub_money, account) - - - if __name__ == '__main__': - main() - ``` - - - 多进程:多进程可以有效的解决GIL的问题,实现多进程主要的类是Process,其他辅助的类跟threading模块中的类似,进程间共享数据可以使用管道、套接字等,在multiprocessing模块中有一个Queue类,它基于管道和锁机制提供了多个进程共享的队列。下面是官方文档上关于多进程和进程池的一个示例。 - - ```Python - """ - 多进程和进程池的使用 - 多线程因为GIL的存在不能够发挥CPU的多核特性 - 对于计算密集型任务应该考虑使用多进程 - time python3 example22.py - real 0m11.512s - user 0m39.319s - sys 0m0.169s - 使用多进程后实际执行时间为11.512秒,而用户时间39.319秒约为实际执行时间的4倍 - 这就证明我们的程序通过多进程使用了CPU的多核特性,而且这台计算机配置了4核的CPU - """ - import concurrent.futures - import math - - PRIMES = [ - 1116281, - 1297337, - 104395303, - 472882027, - 533000389, - 817504243, - 982451653, - 112272535095293, - 112582705942171, - 112272535095293, - 115280095190773, - 115797848077099, - 1099726899285419 - ] * 5 - - - def is_prime(n): - """判断素数""" - if n % 2 == 0: - return False - - sqrt_n = int(math.floor(math.sqrt(n))) - for i in range(3, sqrt_n + 1, 2): - if n % i == 0: - return False - return True - - - def main(): - """主函数""" - with concurrent.futures.ProcessPoolExecutor() as executor: - for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): - print('%d is prime: %s' % (number, prime)) - - - if __name__ == '__main__': - main() - ``` - - > 说明:**多线程和多进程的比较**。 - > - > 以下情况需要使用多线程: - > - > 1. 程序需要维护许多共享的状态(尤其是可变状态),Python中的列表、字典、集合都是线程安全的,所以使用线程而不是进程维护共享状态的代价相对较小。 - > 2. 程序会花费大量时间在I/O操作上,没有太多并行计算的需求且不需占用太多的内存。 - > - > 以下情况需要使用多进程: - > - > 1. 程序执行计算密集型任务(如:字节码操作、数据处理、科学计算)。 - > 2. 程序的输入可以并行的分成块,并且可以将运算结果合并。 - > 3. 程序在内存使用方面没有任何限制且不强依赖于I/O操作(如:读写文件、套接字等)。 - - - 异步处理:从调度程序的任务队列中挑选任务,该调度程序以交叉的形式执行这些任务,我们并不能保证任务将以某种顺序去执行,因为执行顺序取决于队列中的一项任务是否愿意将CPU处理时间让位给另一项任务。异步任务通常通过多任务协作处理的方式来实现,由于执行时间和顺序的不确定,因此需要通过回调式编程或者`future`对象来获取任务执行的结果。Python 3通过`asyncio`模块和`await`和`async`关键字(在Python 3.7中正式被列为关键字)来支持异步处理。 - - ```Python - """ - 异步I/O - async / await - """ - import asyncio - - - def num_generator(m, n): - """指定范围的数字生成器""" - yield from range(m, n + 1) - - - async def prime_filter(m, n): - """素数过滤器""" - primes = [] - for i in num_generator(m, n): - flag = True - for j in range(2, int(i ** 0.5 + 1)): - if i % j == 0: - flag = False - break - if flag: - print('Prime =>', i) - primes.append(i) - - await asyncio.sleep(0.001) - return tuple(primes) - - - async def square_mapper(m, n): - """平方映射器""" - squares = [] - for i in num_generator(m, n): - print('Square =>', i * i) - squares.append(i * i) - - await asyncio.sleep(0.001) - return squares - - - def main(): - """主函数""" - loop = asyncio.get_event_loop() - future = asyncio.gather(prime_filter(2, 100), square_mapper(1, 100)) - future.add_done_callback(lambda x: print(x.result())) - loop.run_until_complete(future) - loop.close() - - - if __name__ == '__main__': - main() - ``` - - > 说明:上面的代码使用`get_event_loop`函数获得系统默认的事件循环,通过`gather`函数可以获得一个`future`对象,`future`对象的`add_done_callback`可以添加执行完成时的回调函数,`loop`对象的`run_until_complete`方法可以等待通过`future`对象获得协程执行结果。 - - Python中有一个名为`aiohttp`的三方库,它提供了异步的HTTP客户端和服务器,这个三方库可以跟`asyncio`模块一起工作,并提供了对`Future`对象的支持。Python 3.6中引入了async和await来定义异步执行的函数以及创建异步上下文,在Python 3.7中它们正式成为了关键字。下面的代码异步的从5个URL中获取页面并通过正则表达式的命名捕获组提取了网站的标题。 - - ```Python - import asyncio - import re - - import aiohttp - - PATTERN = re.compile(r'\(?P.*)\<\/title\>') - - - async def fetch_page(session, url): - async with session.get(url, ssl=False) as resp: - return await resp.text() - - - async def show_title(url): - async with aiohttp.ClientSession() as session: - html = await fetch_page(session, url) - print(PATTERN.search(html).group('title')) - - - def main(): - urls = ('https://www.python.org/', - 'https://git-scm.com/', - 'https://www.jd.com/', - 'https://www.taobao.com/', - 'https://www.douban.com/') - loop = asyncio.get_event_loop() - tasks = [show_title(url) for url in urls] - loop.run_until_complete(asyncio.wait(tasks)) - loop.close() - - - if __name__ == '__main__': - main() - ``` - - > 说明:**异步I/O与多进程的比较**。 - > - > 当程序不需要真正的并发性或并行性,而是更多的依赖于异步处理和回调时,asyncio就是一种很好的选择。如果程序中有大量的等待与休眠时,也应该考虑asyncio,它很适合编写没有实时数据处理需求的Web应用服务器。 - - Python还有很多用于处理并行任务的三方库,例如:joblib、PyMP等。实际开发中,要提升系统的可扩展性和并发性通常有垂直扩展(增加单个节点的处理能力)和水平扩展(将单个节点变成多个节点)两种做法。可以通过消息队列来实现应用程序的解耦合,消息队列相当于是多线程同步队列的扩展版本,不同机器上的应用程序相当于就是线程,而共享的分布式消息队列就是原来程序中的Queue。消息队列(面向消息的中间件)的最流行和最标准化的实现是AMQP(高级消息队列协议),AMQP源于金融行业,提供了排队、路由、可靠传输、安全等功能,最著名的实现包括:Apache的ActiveMQ、RabbitMQ等。 - - 要实现任务的异步化,可以使用名为Celery的三方库。Celery是Python编写的分布式任务队列,它使用分布式消息进行工作,可以基于RabbitMQ或Redis来作为后端的消息代理。 +### 重要知识点 + +- 生成式(推导式)的用法 + + ```Python + prices = { + 'AAPL': 191.88, + 'GOOG': 1186.96, + 'IBM': 149.24, + 'ORCL': 48.44, + 'ACN': 166.89, + 'FB': 208.09, + 'SYMC': 21.29 + } + # 用股票价格大于100元的股票构造一个新的字典 + prices2 = {key: value for key, value in prices.items() if value > 100} + print(prices2) + ``` + + > 说明:生成式(推导式)可以用来生成列表、集合和字典。 + +- 嵌套的列表的坑 + + ```Python + names = ['关羽', '张飞', '赵云', '马超', '黄忠'] + courses = ['语文', '数学', '英语'] + # 录入五个学生三门课程的成绩 + # 错误 - 参考http://pythontutor.com/visualize.html#mode=edit + # scores = [[None] * len(courses)] * len(names) + scores = [[None] * len(courses) for _ in range(len(names))] + for row, name in enumerate(names): + for col, course in enumerate(courses): + scores[row][col] = float(input(f'请输入{name}的{course}成绩: ')) + print(scores) + ``` + + [Python Tutor](http://pythontutor.com/) - VISUALIZE CODE AND GET LIVE HELP + +- `heapq`模块(堆排序) + + ```Python + """ + 从列表中找出最大的或最小的N个元素 + 堆结构(大根堆/小根堆) + """ + import heapq + + list1 = [34, 25, 12, 99, 87, 63, 58, 78, 88, 92] + list2 = [ + {'name': 'IBM', 'shares': 100, 'price': 91.1}, + {'name': 'AAPL', 'shares': 50, 'price': 543.22}, + {'name': 'FB', 'shares': 200, 'price': 21.09}, + {'name': 'HPQ', 'shares': 35, 'price': 31.75}, + {'name': 'YHOO', 'shares': 45, 'price': 16.35}, + {'name': 'ACME', 'shares': 75, 'price': 115.65} + ] + print(heapq.nlargest(3, list1)) + print(heapq.nsmallest(3, list1)) + print(heapq.nlargest(2, list2, key=lambda x: x['price'])) + print(heapq.nlargest(2, list2, key=lambda x: x['shares'])) + ``` + +- `itertools`模块 + + ```Python + """ + 迭代工具模块 + """ + import itertools + + # 产生ABCD的全排列 + itertools.permutations('ABCD') + # 产生ABCDE的五选三组合 + itertools.combinations('ABCDE', 3) + # 产生ABCD和123的笛卡尔积 + itertools.product('ABCD', '123') + # 产生ABC的无限循环序列 + itertools.cycle(('A', 'B', 'C')) + ``` + +- `collections`模块 + + 常用的工具类: + + - `namedtuple`:命令元组,它是一个类工厂,接受类型的名称和属性列表来创建一个类。 + - `deque`:双端队列,是列表的替代实现。Python中的列表底层是基于数组来实现的,而deque底层是双向链表,因此当你需要在头尾添加和删除元素是,deque会表现出更好的性能,渐近时间复杂度为$O(1)$。 + - `Counter`:`dict`的子类,键是元素,值是元素的计数,它的`most_common()`方法可以帮助我们获取出现频率最高的元素。`Counter`和`dict`的继承关系我认为是值得商榷的,按照CARP原则,`Counter`跟`dict`的关系应该设计为关联关系更为合理。 + - `OrderedDict`:`dict`的子类,它记录了键值对插入的顺序,看起来既有字典的行为,也有链表的行为。 + - `defaultdict`:类似于字典类型,但是可以通过默认的工厂函数来获得键对应的默认值,相比字典中的`setdefault()`方法,这种做法更加高效。 + + ```Python + """ + 找出序列中出现次数最多的元素 + """ + from collections import Counter + + words = [ + 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', + 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', + 'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes', + 'look', 'into', 'my', 'eyes', "you're", 'under' + ] + counter = Counter(words) + print(counter.most_common(3)) + ``` + +### 数据结构和算法 + +- 算法:解决问题的方法和步骤 + +- 评价算法的好坏:渐近时间复杂度和渐近空间复杂度。 + +- 渐近时间复杂度的大O标记: + - <img src="http://latex.codecogs.com/gif.latex?O(c)" /> - 常量时间复杂度 - 布隆过滤器 / 哈希存储 + - <img src="http://latex.codecogs.com/gif.latex?O(log_2n)" /> - 对数时间复杂度 - 折半查找(二分查找) + - <img src="http://latex.codecogs.com/gif.latex?O(n)" /> - 线性时间复杂度 - 顺序查找 / 计数排序 + - <img src="http://latex.codecogs.com/gif.latex?O(n*log_2n)" /> - 对数线性时间复杂度 - 高级排序算法(归并排序、快速排序) + - <img src="http://latex.codecogs.com/gif.latex?O(n^2)" /> - 平方时间复杂度 - 简单排序算法(选择排序、插入排序、冒泡排序) + - <img src="http://latex.codecogs.com/gif.latex?O(n^3)" /> - 立方时间复杂度 - Floyd算法 / 矩阵乘法运算 + - <img src="http://latex.codecogs.com/gif.latex?O(2^n)" /> - 几何级数时间复杂度 - 汉诺塔 + - <img src="http://latex.codecogs.com/gif.latex?O(n!)" /> - 阶乘时间复杂度 - 旅行经销商问题 - NPC + + ![](./res/algorithm_complexity_1.png) + + ![](./res/algorithm_complexity_2.png) + +- 排序算法(选择、冒泡和归并)和查找算法(顺序和折半) + + ```Python + def select_sort(items, comp=lambda x, y: x < y): + """简单选择排序""" + items = items[:] + for i in range(len(items) - 1): + min_index = i + for j in range(i + 1, len(items)): + if comp(items[j], items[min_index]): + min_index = j + items[i], items[min_index] = items[min_index], items[i] + return items + ``` + + ```Python + def bubble_sort(items, comp=lambda x, y: x > y): + """冒泡排序""" + items = items[:] + for i in range(len(items) - 1): + swapped = False + for j in range(len(items) - 1 - i): + if comp(items[j], items[j + 1]): + items[j], items[j + 1] = items[j + 1], items[j] + swapped = True + if not swapped: + break + return items + ``` + + ```Python + def bubble_sort(items, comp=lambda x, y: x > y): + """搅拌排序(冒泡排序升级版)""" + items = items[:] + for i in range(len(items) - 1): + swapped = False + for j in range(len(items) - 1 - i): + if comp(items[j], items[j + 1]): + items[j], items[j + 1] = items[j + 1], items[j] + swapped = True + if swapped: + swapped = False + for j in range(len(items) - 2 - i, i, -1): + if comp(items[j - 1], items[j]): + items[j], items[j - 1] = items[j - 1], items[j] + swapped = True + if not swapped: + break + return items + ``` + + ```Python + def merge(items1, items2, comp=lambda x, y: x < y): + """合并(将两个有序的列表合并成一个有序的列表)""" + items = [] + index1, index2 = 0, 0 + while index1 < len(items1) and index2 < len(items2): + if comp(items1[index1], items2[index2]): + items.append(items1[index1]) + index1 += 1 + else: + items.append(items2[index2]) + index2 += 1 + items += items1[index1:] + items += items2[index2:] + return items + + + def merge_sort(items, comp=lambda x, y: x < y): + return _merge_sort(list(items), comp) + + + def _merge_sort(items, comp): + """归并排序""" + if len(items) < 2: + return items + mid = len(items) // 2 + left = _merge_sort(items[:mid], comp) + right = _merge_sort(items[mid:], comp) + return merge(left, right, comp) + ``` + + ```Python + def seq_search(items, key): + """顺序查找""" + for index, item in enumerate(items): + if item == key: + return index + return -1 + ``` + + ```Python + def bin_search(items, key): + """折半查找""" + start, end = 0, len(items) - 1 + while start <= end: + mid = (start + end) // 2 + if key > items[mid]: + start = mid + 1 + elif key < items[mid]: + end = mid - 1 + else: + return mid + return -1 + ``` + +- 常用算法: + + - 穷举法 - 又称为暴力破解法,对所有的可能性进行验证,直到找到正确答案。 + - 贪婪法 - 在对问题求解时,总是做出在当前看来 + - 最好的选择,不追求最优解,快速找到满意解。 + - 分治法 - 把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题,直到可以直接求解的程度,最后将子问题的解进行合并得到原问题的解。 + - 回溯法 - 回溯法又称为试探法,按选优条件向前搜索,当搜索到某一步发现原先选择并不优或达不到目标时,就退回一步重新选择。 + - 动态规划 - 基本思想也是将待求解问题分解成若干个子问题,先求解并保存这些子问题的解,避免产生大量的重复运算。 + + 穷举法例子:百钱百鸡和五人分鱼。 + + ```Python + # 公鸡5元一只 母鸡3元一只 小鸡1元三只 + # 用100元买100只鸡 问公鸡/母鸡/小鸡各多少只 + for x in range(20): + for y in range(33): + z = 100 - x - y + if 5 * x + 3 * y + z // 3 == 100 and z % 3 == 0: + print(x, y, z) + + # A、B、C、D、E五人在某天夜里合伙捕鱼 最后疲惫不堪各自睡觉 + # 第二天A第一个醒来 他将鱼分为5份 扔掉多余的1条 拿走自己的一份 + # B第二个醒来 也将鱼分为5份 扔掉多余的1条 拿走自己的一份 + # 然后C、D、E依次醒来也按同样的方式分鱼 问他们至少捕了多少条鱼 + fish = 6 + while True: + total = fish + enough = True + for _ in range(5): + if (total - 1) % 5 == 0: + total = (total - 1) // 5 * 4 + else: + enough = False + break + if enough: + print(fish) + break + fish += 5 + ``` + + 贪婪法例子:假设小偷有一个背包,最多能装20公斤赃物,他闯入一户人家,发现如下表所示的物品。很显然,他不能把所有物品都装进背包,所以必须确定拿走哪些物品,留下哪些物品。 + + | 名称 | 价格(美元) | 重量(kg) | + | :----: | :----------: | :--------: | + | 电脑 | 200 | 20 | + | 收音机 | 20 | 4 | + | 钟 | 175 | 10 | + | 花瓶 | 50 | 2 | + | 书 | 10 | 1 | + | 油画 | 90 | 9 | + + ```Python + """ + 贪婪法:在对问题求解时,总是做出在当前看来是最好的选择,不追求最优解,快速找到满意解。 + 输入: + 20 6 + 电脑 200 20 + 收音机 20 4 + 钟 175 10 + 花瓶 50 2 + 书 10 1 + 油画 90 9 + """ + class Thing(object): + """物品""" + + def __init__(self, name, price, weight): + self.name = name + self.price = price + self.weight = weight + + @property + def value(self): + """价格重量比""" + return self.price / self.weight + + + def input_thing(): + """输入物品信息""" + name_str, price_str, weight_str = input().split() + return name_str, int(price_str), int(weight_str) + + + def main(): + """主函数""" + max_weight, num_of_things = map(int, input().split()) + all_things = [] + for _ in range(num_of_things): + all_things.append(Thing(*input_thing())) + all_things.sort(key=lambda x: x.value, reverse=True) + total_weight = 0 + total_price = 0 + for thing in all_things: + if total_weight + thing.weight <= max_weight: + print(f'小偷拿走了{thing.name}') + total_weight += thing.weight + total_price += thing.price + print(f'总价值: {total_price}美元') + + + if __name__ == '__main__': + main() + ``` + + 分治法例子:[快速排序](https://zh.wikipedia.org/zh/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F)。 + + ```Python + """ + 快速排序 - 选择枢轴对元素进行划分,左边都比枢轴小右边都比枢轴大 + """ + def quick_sort(items, comp=lambda x, y: x <= y): + items = list(items)[:] + _quick_sort(items, 0, len(items) - 1, comp) + return items + + + def _quick_sort(items, start, end, comp): + if start < end: + pos = _partition(items, start, end, comp) + _quick_sort(items, start, pos - 1, comp) + _quick_sort(items, pos + 1, end, comp) + + + def _partition(items, start, end, comp): + pivot = items[end] + i = start - 1 + for j in range(start, end): + if comp(items[j], pivot): + i += 1 + items[i], items[j] = items[j], items[i] + items[i + 1], items[end] = items[end], items[i + 1] + return i + 1 + ``` + + 回溯法例子:[骑士巡逻](https://zh.wikipedia.org/zh/%E9%AA%91%E5%A3%AB%E5%B7%A1%E9%80%BB)。 + + ```Python + """ + 递归回溯法:叫称为试探法,按选优条件向前搜索,当搜索到某一步,发现原先选择并不优或达不到目标时,就退回一步重新选择,比较经典的问题包括骑士巡逻、八皇后和迷宫寻路等。 + """ + import sys + import time + + SIZE = 5 + total = 0 + + + def print_board(board): + for row in board: + for col in row: + print(str(col).center(4), end='') + print() + + + def patrol(board, row, col, step=1): + if row >= 0 and row < SIZE and \ + col >= 0 and col < SIZE and \ + board[row][col] == 0: + board[row][col] = step + if step == SIZE * SIZE: + global total + total += 1 + print(f'第{total}种走法: ') + print_board(board) + patrol(board, row - 2, col - 1, step + 1) + patrol(board, row - 1, col - 2, step + 1) + patrol(board, row + 1, col - 2, step + 1) + patrol(board, row + 2, col - 1, step + 1) + patrol(board, row + 2, col + 1, step + 1) + patrol(board, row + 1, col + 2, step + 1) + patrol(board, row - 1, col + 2, step + 1) + patrol(board, row - 2, col + 1, step + 1) + board[row][col] = 0 + + + def main(): + board = [[0] * SIZE for _ in range(SIZE)] + patrol(board, SIZE - 1, SIZE - 1) + + + if __name__ == '__main__': + main() + ``` + + 动态规划例子:子列表元素之和的最大值。 + + > 说明:子列表指的是列表中索引(下标)连续的元素构成的列表;列表中的元素是int类型,可能包含正整数、0、负整数;程序输入列表中的元素,输出子列表元素求和的最大值,例如: + > + > 输入:1 -2 3 5 -3 2 + > + > 输出:8 + > + > 输入:0 -2 3 5 -1 2 + > + > 输出:9 + > + > 输入:-9 -2 -3 -5 -3 + > + > 输出:-2 + + ```Python + def main(): + items = list(map(int, input().split())) + overall = partial = items[0] + for i in range(1, len(items)): + partial = max(items[i], partial + items[i]) + overall = max(partial, overall) + print(overall) + + + if __name__ == '__main__': + main() + ``` + + > **说明**:这个题目最容易想到的解法是使用二重循环,但是代码的时间性能将会变得非常的糟糕。使用动态规划的思想,仅仅是多用了两个变量,就将原来$O(N^2)$复杂度的问题变成了$O(N)$。 + +### 函数的使用方式 + +- 将函数视为“一等公民” + + - 函数可以赋值给变量 + - 函数可以作为函数的参数 + - 函数可以作为函数的返回值 + +- 高阶函数的用法(`filter`、`map`以及它们的替代品) + + ```Python + items1 = list(map(lambda x: x ** 2, filter(lambda x: x % 2, range(1, 10)))) + items2 = [x ** 2 for x in range(1, 10) if x % 2] + ``` + +- 位置参数、可变参数、关键字参数、命名关键字参数 + +- 参数的元信息(代码可读性问题) + +- 匿名函数和内联函数的用法(`lambda`函数) + +- 闭包和作用域问题 + + - Python搜索变量的LEGB顺序(Local >>> Embedded >>> Global >>> Built-in) + + - `global`和`nonlocal`关键字的作用 + + `global`:声明或定义全局变量(要么直接使用现有的全局作用域的变量,要么定义一个变量放到全局作用域)。 + + `nonlocal`:声明使用嵌套作用域的变量(嵌套作用域必须存在该变量,否则报错)。 + +- 装饰器函数(使用装饰器和取消装饰器) + + 例子:输出函数执行时间的装饰器。 + + ```Python + def record_time(func): + """自定义装饰函数的装饰器""" + + @wraps(func) + def wrapper(*args, **kwargs): + start = time() + result = func(*args, **kwargs) + print(f'{func.__name__}: {time() - start}秒') + return result + + return wrapper + ``` + + 如果装饰器不希望跟`print`函数耦合,可以编写可以参数化的装饰器。 + + ```Python + from functools import wraps + from time import time + + + def record(output): + """可以参数化的装饰器""" + + def decorate(func): + + @wraps(func) + def wrapper(*args, **kwargs): + start = time() + result = func(*args, **kwargs) + output(func.__name__, time() - start) + return result + + return wrapper + + return decorate + ``` + + ```Python + from functools import wraps + from time import time + + + class Record(): + """通过定义类的方式定义装饰器""" + + def __init__(self, output): + self.output = output + + def __call__(self, func): + + @wraps(func) + def wrapper(*args, **kwargs): + start = time() + result = func(*args, **kwargs) + self.output(func.__name__, time() - start) + return result + + return wrapper + ``` + + > **说明**:由于对带装饰功能的函数添加了@wraps装饰器,可以通过`func.__wrapped__`方式获得被装饰之前的函数或类来取消装饰器的作用。 + + 例子:用装饰器来实现单例模式。 + + ```Python + from functools import wraps + + + def singleton(cls): + """装饰类的装饰器""" + instances = {} + + @wraps(cls) + def wrapper(*args, **kwargs): + if cls not in instances: + instances[cls] = cls(*args, **kwargs) + return instances[cls] + + return wrapper + + + @singleton + class President: + """总统(单例类)""" + pass + ``` + + > **提示**:上面的代码中用到了闭包(closure),不知道你是否已经意识到了。还没有一个小问题就是,上面的代码并没有实现线程安全的单例,如果要实现线程安全的单例应该怎么做呢? + + 线程安全的单例装饰器。 + + ```Python + from functools import wraps + from threading import RLock + + + def singleton(cls): + """线程安全的单例装饰器""" + instances = {} + locker = RLock() + + @wraps(cls) + def wrapper(*args, **kwargs): + if cls not in instances: + with locker: + if cls not in instances: + instances[cls] = cls(*args, **kwargs) + return instances[cls] + + return wrapper + ``` + + > **提示**:上面的代码用到了`with`上下文语法来进行锁操作,因为锁对象本身就是上下文管理器对象(支持`__enter__`和`__exit__`魔术方法)。在`wrapper`函数中,我们先做了一次不带锁的检查,然后再做带锁的检查,这样做比直接加锁检查性能要更好,如果对象已经创建就没有必须再去加锁而是直接返回该对象就可以了。 + +### 面向对象相关知识 + +- 三大支柱:封装、继承、多态 + + 例子:工资结算系统。 + + ```Python + """ + 月薪结算系统 - 部门经理每月15000 程序员每小时200 销售员1800底薪加销售额5%提成 + """ + from abc import ABCMeta, abstractmethod + + + class Employee(metaclass=ABCMeta): + """员工(抽象类)""" + + def __init__(self, name): + self.name = name + + @abstractmethod + def get_salary(self): + """结算月薪(抽象方法)""" + pass + + + class Manager(Employee): + """部门经理""" + + def get_salary(self): + return 15000.0 + + + class Programmer(Employee): + """程序员""" + + def __init__(self, name, working_hour=0): + self.working_hour = working_hour + super().__init__(name) + + def get_salary(self): + return 200.0 * self.working_hour + + + class Salesman(Employee): + """销售员""" + + def __init__(self, name, sales=0.0): + self.sales = sales + super().__init__(name) + + def get_salary(self): + return 1800.0 + self.sales * 0.05 + + + class EmployeeFactory: + """创建员工的工厂(工厂模式 - 通过工厂实现对象使用者和对象之间的解耦合)""" + + @staticmethod + def create(emp_type, *args, **kwargs): + """创建员工""" + all_emp_types = {'M': Manager, 'P': Programmer, 'S': Salesman} + cls = all_emp_types[emp_type.upper()] + return cls(*args, **kwargs) if cls else None + + + def main(): + """主函数""" + emps = [ + EmployeeFactory.create('M', '曹操'), + EmployeeFactory.create('P', '荀彧', 120), + EmployeeFactory.create('P', '郭嘉', 85), + EmployeeFactory.create('S', '典韦', 123000), + ] + for emp in emps: + print(f'{emp.name}: {emp.get_salary():.2f}元') + + + if __name__ == '__main__': + main() + ``` + +- 类与类之间的关系 + + - is-a关系:继承 + - has-a关系:关联 / 聚合 / 合成 + - use-a关系:依赖 + + 例子:扑克游戏。 + + ```Python + """ + 经验:符号常量总是优于字面常量,枚举类型是定义符号常量的最佳选择 + """ + from enum import Enum, unique + + import random + + + @unique + class Suite(Enum): + """花色""" + + SPADE, HEART, CLUB, DIAMOND = range(4) + + def __lt__(self, other): + return self.value < other.value + + + class Card(): + """牌""" + + def __init__(self, suite, face): + """初始化方法""" + self.suite = suite + self.face = face + + def show(self): + """显示牌面""" + suites = ['♠︎', '♥︎', '♣︎', '♦︎'] + faces = ['', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] + return f'{suites[self.suite.value]}{faces[self.face]}' + + def __repr__(self): + return self.show() + + + class Poker(): + """扑克""" + + def __init__(self): + self.index = 0 + self.cards = [Card(suite, face) + for suite in Suite + for face in range(1, 14)] + + def shuffle(self): + """洗牌(随机乱序)""" + random.shuffle(self.cards) + self.index = 0 + + def deal(self): + """发牌""" + card = self.cards[self.index] + self.index += 1 + return card + + @property + def has_more(self): + return self.index < len(self.cards) + + + class Player(): + """玩家""" + + def __init__(self, name): + self.name = name + self.cards = [] + + def get_one(self, card): + """摸一张牌""" + self.cards.append(card) + + def sort(self, comp=lambda card: (card.suite, card.face)): + """整理手上的牌""" + self.cards.sort(key=comp) + + + def main(): + """主函数""" + poker = Poker() + poker.shuffle() + players = [Player('东邪'), Player('西毒'), Player('南帝'), Player('北丐')] + while poker.has_more: + for player in players: + player.get_one(poker.deal()) + for player in players: + player.sort() + print(player.name, end=': ') + print(player.cards) + + + if __name__ == '__main__': + main() + ``` + + > **说明**:上面的代码中使用了Emoji字符来表示扑克牌的四种花色,在某些不支持Emoji字符的系统上可能无法显示。 + +- 对象的复制(深复制/深拷贝/深度克隆和浅复制/浅拷贝/影子克隆) + +- 垃圾回收、循环引用和弱引用 + + Python使用了自动化内存管理,这种管理机制以**引用计数**为基础,同时也引入了**标记-清除**和**分代收集**两种机制为辅的策略。 + + ```C + typedef struct _object { + /* 引用计数 */ + int ob_refcnt; + /* 对象指针 */ + struct _typeobject *ob_type; + } PyObject; + ``` + + ```C + /* 增加引用计数的宏定义 */ + #define Py_INCREF(op) ((op)->ob_refcnt++) + /* 减少引用计数的宏定义 */ + #define Py_DECREF(op) \ //减少计数 + if (--(op)->ob_refcnt != 0) \ + ; \ + else \ + __Py_Dealloc((PyObject *)(op)) + ``` + + 导致引用计数+1的情况: + + - 对象被创建,例如`a = 23` + - 对象被引用,例如`b = a` + - 对象被作为参数,传入到一个函数中,例如`f(a)` + - 对象作为一个元素,存储在容器中,例如`list1 = [a, a]` + + 导致引用计数-1的情况: + + - 对象的别名被显式销毁,例如`del a` + - 对象的别名被赋予新的对象,例如`a = 24` + - 一个对象离开它的作用域,例如f函数执行完毕时,f函数中的局部变量(全局变量不会) + - 对象所在的容器被销毁,或从容器中删除对象 + + 引用计数可能会导致循环引用问题,而循环引用会导致内存泄露,如下面的代码所示。为了解决这个问题,Python中引入了“标记-清除”和“分代收集”。在创建一个对象的时候,对象被放在第一代中,如果在第一代的垃圾检查中对象存活了下来,该对象就会被放到第二代中,同理在第二代的垃圾检查中对象存活下来,该对象就会被放到第三代中。 + + ```Python + # 循环引用会导致内存泄露 - Python除了引用技术还引入了标记清理和分代回收 + # 在Python 3.6以前如果重写__del__魔术方法会导致循环引用处理失效 + # 如果不想造成循环引用可以使用弱引用 + list1 = [] + list2 = [] + list1.append(list2) + list2.append(list1) + ``` + + 以下情况会导致垃圾回收: + + - 调用`gc.collect()` + - `gc`模块的计数器达到阀值 + - 程序退出 + + 如果循环引用中两个对象都定义了`__del__`方法,`gc`模块不会销毁这些不可达对象,因为gc模块不知道应该先调用哪个对象的`__del__`方法,这个问题在Python 3.6中得到了解决。 + + 也可以通过`weakref`模块构造弱引用的方式来解决循环引用的问题。 + +- 魔法属性和方法(请参考《Python魔法方法指南》) + + 有几个小问题请大家思考: + + - 自定义的对象能不能使用运算符做运算? + - 自定义的对象能不能放到`set`中?能去重吗? + - 自定义的对象能不能作为`dict`的键? + - 自定义的对象能不能使用上下文语法? + +- 混入(Mixin) + + 例子:自定义字典限制只有在指定的key不存在时才能在字典中设置键值对。 + + ```Python + class SetOnceMappingMixin: + """自定义混入类""" + __slots__ = () + + def __setitem__(self, key, value): + if key in self: + raise KeyError(str(key) + ' already set') + return super().__setitem__(key, value) + + + class SetOnceDict(SetOnceMappingMixin, dict): + """自定义字典""" + pass + + + my_dict= SetOnceDict() + try: + my_dict['username'] = 'jackfrued' + my_dict['username'] = 'hellokitty' + except KeyError: + pass + print(my_dict) + ``` + +- 元编程和元类 + + 对象是通过类创建的,类是通过元类创建的,元类提供了创建类的元信息。所有的类都直接或间接的继承自`object`,所有的元类都直接或间接的继承自`type`。 + + 例子:用元类实现单例模式。 + + ```Python + import threading + + + class SingletonMeta(type): + """自定义元类""" + + def __init__(cls, *args, **kwargs): + cls.__instance = None + cls.__lock = threading.RLock() + super().__init__(*args, **kwargs) + + def __call__(cls, *args, **kwargs): + if cls.__instance is None: + with cls.__lock: + if cls.__instance is None: + cls.__instance = super().__call__(*args, **kwargs) + return cls.__instance + + + class President(metaclass=SingletonMeta): + """总统(单例类)""" + + pass + ``` + +- 面向对象设计原则 + + - 单一职责原则 (**S**RP)- 一个类只做该做的事情(类的设计要高内聚) + - 开闭原则 (**O**CP)- 软件实体应该对扩展开发对修改关闭 + - 依赖倒转原则(DIP)- 面向抽象编程(在弱类型语言中已经被弱化) + - 里氏替换原则(**L**SP) - 任何时候可以用子类对象替换掉父类对象 + - 接口隔离原则(**I**SP)- 接口要小而专不要大而全(Python中没有接口的概念) + - 合成聚合复用原则(CARP) - 优先使用强关联关系而不是继承关系复用代码 + - 最少知识原则(迪米特法则,Lo**D**)- 不要给没有必然联系的对象发消息 + + > **说明**:上面加粗的字母放在一起称为面向对象的**SOLID**原则。 + +- GoF设计模式 + + - 创建型模式:单例、工厂、建造者、原型 + - 结构型模式:适配器、门面(外观)、代理 + - 行为型模式:迭代器、观察者、状态、策略 + + 例子:可插拔的哈希算法(策略模式)。 + + ```Python + class StreamHasher(): + """哈希摘要生成器""" + + def __init__(self, alg='md5', size=4096): + self.size = size + alg = alg.lower() + self.hasher = getattr(__import__('hashlib'), alg.lower())() + + def __call__(self, stream): + return self.to_digest(stream) + + def to_digest(self, stream): + """生成十六进制形式的摘要""" + for buf in iter(lambda: stream.read(self.size), b''): + self.hasher.update(buf) + return self.hasher.hexdigest() + + def main(): + """主函数""" + hasher1 = StreamHasher() + with open('Python-3.7.6.tgz', 'rb') as stream: + print(hasher1.to_digest(stream)) + hasher2 = StreamHasher('sha1') + with open('Python-3.7.6.tgz', 'rb') as stream: + print(hasher2(stream)) + + + if __name__ == '__main__': + main() + ``` + +### 迭代器和生成器 + +- 迭代器是实现了迭代器协议的对象。 + + - Python中没有像`protocol`或`interface`这样的定义协议的关键字。 + - Python中用魔术方法表示协议。 + - `__iter__`和`__next__`魔术方法就是迭代器协议。 + + ```Python + class Fib(object): + """迭代器""" + + def __init__(self, num): + self.num = num + self.a, self.b = 0, 1 + self.idx = 0 + + def __iter__(self): + return self + + def __next__(self): + if self.idx < self.num: + self.a, self.b = self.b, self.a + self.b + self.idx += 1 + return self.a + raise StopIteration() + ``` + +- 生成器是语法简化版的迭代器。 + + ```Python + def fib(num): + """生成器""" + a, b = 0, 1 + for _ in range(num): + a, b = b, a + b + yield a + ``` + +- 生成器进化为协程。 + + 生成器对象可以使用`send()`方法发送数据,发送的数据会成为生成器函数中通过`yield`表达式获得的值。这样,生成器就可以作为协程使用,协程简单的说就是可以相互协作的子程序。 + + ```Python + def calc_avg(): + """流式计算平均值""" + total, counter = 0, 0 + avg_value = None + while True: + value = yield avg_value + total, counter = total + value, counter + 1 + avg_value = total / counter + + + gen = calc_avg() + next(gen) + print(gen.send(10)) + print(gen.send(20)) + print(gen.send(30)) + ``` + +### 并发编程 + +Python中实现并发编程的三种方案:多线程、多进程和异步I/O。并发编程的好处在于可以提升程序的执行效率以及改善用户体验;坏处在于并发的程序不容易开发和调试,同时对其他程序来说它并不友好。 + +- 多线程:Python中提供了`Thread`类并辅以`Lock`、`Condition`、`Event`、`Semaphore`和`Barrier`。Python中有GIL来防止多个线程同时执行本地字节码,这个锁对于CPython是必须的,因为CPython的内存管理并不是线程安全的,因为GIL的存在多线程并不能发挥CPU的多核特性。 + + ```Python + """ + 面试题:进程和线程的区别和联系? + 进程 - 操作系统分配内存的基本单位 - 一个进程可以包含一个或多个线程 + 线程 - 操作系统分配CPU的基本单位 + 并发编程(concurrent programming) + 1. 提升执行性能 - 让程序中没有因果关系的部分可以并发的执行 + 2. 改善用户体验 - 让耗时间的操作不会造成程序的假死 + """ + import glob + import os + import threading + + from PIL import Image + + PREFIX = 'thumbnails' + + + def generate_thumbnail(infile, size, format='PNG'): + """生成指定图片文件的缩略图""" + file, ext = os.path.splitext(infile) + file = file[file.rfind('/') + 1:] + outfile = f'{PREFIX}/{file}_{size[0]}_{size[1]}.{ext}' + img = Image.open(infile) + img.thumbnail(size, Image.ANTIALIAS) + img.save(outfile, format) + + + def main(): + """主函数""" + if not os.path.exists(PREFIX): + os.mkdir(PREFIX) + for infile in glob.glob('images/*.png'): + for size in (32, 64, 128): + # 创建并启动线程 + threading.Thread( + target=generate_thumbnail, + args=(infile, (size, size)) + ).start() + + + if __name__ == '__main__': + main() + ``` + + 多个线程竞争资源的情况。 + + ```Python + """ + 多线程程序如果没有竞争资源处理起来通常也比较简单 + 当多个线程竞争临界资源的时候如果缺乏必要的保护措施就会导致数据错乱 + 说明:临界资源就是被多个线程竞争的资源 + """ + import time + import threading + + from concurrent.futures import ThreadPoolExecutor + + + class Account(object): + """银行账户""" + + def __init__(self): + self.balance = 0.0 + self.lock = threading.Lock() + + def deposit(self, money): + # 通过锁保护临界资源 + with self.lock: + new_balance = self.balance + money + time.sleep(0.001) + self.balance = new_balance + + + class AddMoneyThread(threading.Thread): + """自定义线程类""" + + def __init__(self, account, money): + self.account = account + self.money = money + # 自定义线程的初始化方法中必须调用父类的初始化方法 + super().__init__() + + def run(self): + # 线程启动之后要执行的操作 + self.account.deposit(self.money) + + def main(): + """主函数""" + account = Account() + # 创建线程池 + pool = ThreadPoolExecutor(max_workers=10) + futures = [] + for _ in range(100): + # 创建线程的第1种方式 + # threading.Thread( + # target=account.deposit, args=(1, ) + # ).start() + # 创建线程的第2种方式 + # AddMoneyThread(account, 1).start() + # 创建线程的第3种方式 + # 调用线程池中的线程来执行特定的任务 + future = pool.submit(account.deposit, 1) + futures.append(future) + # 关闭线程池 + pool.shutdown() + for future in futures: + future.result() + print(account.balance) + + + if __name__ == '__main__': + main() + ``` + + 修改上面的程序,启动5个线程向账户中存钱,5个线程从账户中取钱,取钱时如果余额不足就暂停线程进行等待。为了达到上述目标,需要对存钱和取钱的线程进行调度,在余额不足时取钱的线程暂停并释放锁,而存钱的线程将钱存入后要通知取钱的线程,使其从暂停状态被唤醒。可以使用`threading`模块的`Condition`来实现线程调度,该对象也是基于锁来创建的,代码如下所示: + + ```Python + """ + 多个线程竞争一个资源 - 保护临界资源 - 锁(Lock/RLock) + 多个线程竞争多个资源(线程数>资源数) - 信号量(Semaphore) + 多个线程的调度 - 暂停线程执行/唤醒等待中的线程 - Condition + """ + from concurrent.futures import ThreadPoolExecutor + from random import randint + from time import sleep + + import threading + + + class Account: + """银行账户""" + + def __init__(self, balance=0): + self.balance = balance + lock = threading.RLock() + self.condition = threading.Condition(lock) + + def withdraw(self, money): + """取钱""" + with self.condition: + while money > self.balance: + self.condition.wait() + new_balance = self.balance - money + sleep(0.001) + self.balance = new_balance + + def deposit(self, money): + """存钱""" + with self.condition: + new_balance = self.balance + money + sleep(0.001) + self.balance = new_balance + self.condition.notify_all() + + + def add_money(account): + while True: + money = randint(5, 10) + account.deposit(money) + print(threading.current_thread().name, + ':', money, '====>', account.balance) + sleep(0.5) + + + def sub_money(account): + while True: + money = randint(10, 30) + account.withdraw(money) + print(threading.current_thread().name, + ':', money, '<====', account.balance) + sleep(1) + + + def main(): + account = Account() + with ThreadPoolExecutor(max_workers=15) as pool: + for _ in range(5): + pool.submit(add_money, account) + for _ in range(10): + pool.submit(sub_money, account) + + + if __name__ == '__main__': + main() + ``` + +- 多进程:多进程可以有效的解决GIL的问题,实现多进程主要的类是`Process`,其他辅助的类跟`threading`模块中的类似,进程间共享数据可以使用管道、套接字等,在`multiprocessing`模块中有一个`Queue`类,它基于管道和锁机制提供了多个进程共享的队列。下面是官方文档上关于多进程和进程池的一个示例。 + + ```Python + """ + 多进程和进程池的使用 + 多线程因为GIL的存在不能够发挥CPU的多核特性 + 对于计算密集型任务应该考虑使用多进程 + time python3 example22.py + real 0m11.512s + user 0m39.319s + sys 0m0.169s + 使用多进程后实际执行时间为11.512秒,而用户时间39.319秒约为实际执行时间的4倍 + 这就证明我们的程序通过多进程使用了CPU的多核特性,而且这台计算机配置了4核的CPU + """ + import concurrent.futures + import math + + PRIMES = [ + 1116281, + 1297337, + 104395303, + 472882027, + 533000389, + 817504243, + 982451653, + 112272535095293, + 112582705942171, + 112272535095293, + 115280095190773, + 115797848077099, + 1099726899285419 + ] * 5 + + + def is_prime(n): + """判断素数""" + if n % 2 == 0: + return False + + sqrt_n = int(math.floor(math.sqrt(n))) + for i in range(3, sqrt_n + 1, 2): + if n % i == 0: + return False + return True + + + def main(): + """主函数""" + with concurrent.futures.ProcessPoolExecutor() as executor: + for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): + print('%d is prime: %s' % (number, prime)) + + + if __name__ == '__main__': + main() + ``` + + > **重点**:**多线程和多进程的比较**。 + > + > 以下情况需要使用多线程: + > + > 1. 程序需要维护许多共享的状态(尤其是可变状态),Python中的列表、字典、集合都是线程安全的,所以使用线程而不是进程维护共享状态的代价相对较小。 + > 2. 程序会花费大量时间在I/O操作上,没有太多并行计算的需求且不需占用太多的内存。 + > + > 以下情况需要使用多进程: + > + > 1. 程序执行计算密集型任务(如:字节码操作、数据处理、科学计算)。 + > 2. 程序的输入可以并行的分成块,并且可以将运算结果合并。 + > 3. 程序在内存使用方面没有任何限制且不强依赖于I/O操作(如:读写文件、套接字等)。 + +- 异步处理:从调度程序的任务队列中挑选任务,该调度程序以交叉的形式执行这些任务,我们并不能保证任务将以某种顺序去执行,因为执行顺序取决于队列中的一项任务是否愿意将CPU处理时间让位给另一项任务。异步任务通常通过多任务协作处理的方式来实现,由于执行时间和顺序的不确定,因此需要通过回调式编程或者`future`对象来获取任务执行的结果。Python 3通过`asyncio`模块和`await`和`async`关键字(在Python 3.7中正式被列为关键字)来支持异步处理。 + + ```Python + """ + 异步I/O - async / await + """ + import asyncio + + + def num_generator(m, n): + """指定范围的数字生成器""" + yield from range(m, n + 1) + + + async def prime_filter(m, n): + """素数过滤器""" + primes = [] + for i in num_generator(m, n): + flag = True + for j in range(2, int(i ** 0.5 + 1)): + if i % j == 0: + flag = False + break + if flag: + print('Prime =>', i) + primes.append(i) + + await asyncio.sleep(0.001) + return tuple(primes) + + + async def square_mapper(m, n): + """平方映射器""" + squares = [] + for i in num_generator(m, n): + print('Square =>', i * i) + squares.append(i * i) + + await asyncio.sleep(0.001) + return squares + + + def main(): + """主函数""" + loop = asyncio.get_event_loop() + future = asyncio.gather(prime_filter(2, 100), square_mapper(1, 100)) + future.add_done_callback(lambda x: print(x.result())) + loop.run_until_complete(future) + loop.close() + + + if __name__ == '__main__': + main() + ``` + + > **说明**:上面的代码使用`get_event_loop`函数获得系统默认的事件循环,通过`gather`函数可以获得一个`future`对象,`future`对象的`add_done_callback`可以添加执行完成时的回调函数,`loop`对象的`run_until_complete`方法可以等待通过`future`对象获得协程执行结果。 + + Python中有一个名为`aiohttp`的三方库,它提供了异步的HTTP客户端和服务器,这个三方库可以跟`asyncio`模块一起工作,并提供了对`Future`对象的支持。Python 3.6中引入了`async`和`await`来定义异步执行的函数以及创建异步上下文,在Python 3.7中它们正式成为了关键字。下面的代码异步的从5个URL中获取页面并通过正则表达式的命名捕获组提取了网站的标题。 + + ```Python + import asyncio + import re + + import aiohttp + + PATTERN = re.compile(r'\<title\>(?P<title>.*)\<\/title\>') + + + async def fetch_page(session, url): + async with session.get(url, ssl=False) as resp: + return await resp.text() + + + async def show_title(url): + async with aiohttp.ClientSession() as session: + html = await fetch_page(session, url) + print(PATTERN.search(html).group('title')) + + + def main(): + urls = ('https://www.python.org/', + 'https://git-scm.com/', + 'https://www.jd.com/', + 'https://www.taobao.com/', + 'https://www.douban.com/') + loop = asyncio.get_event_loop() + cos = [show_title(url) for url in urls] + loop.run_until_complete(asyncio.wait(cos)) + loop.close() + + + if __name__ == '__main__': + main() + ``` + + > **重点**:**异步I/O与多进程的比较**。 + > + > 当程序不需要真正的并发性或并行性,而是更多的依赖于异步处理和回调时,`asyncio`就是一种很好的选择。如果程序中有大量的等待与休眠时,也应该考虑`asyncio`,它很适合编写没有实时数据处理需求的Web应用服务器。 + + Python还有很多用于处理并行任务的三方库,例如:`joblib`、`PyMP`等。实际开发中,要提升系统的可扩展性和并发性通常有垂直扩展(增加单个节点的处理能力)和水平扩展(将单个节点变成多个节点)两种做法。可以通过消息队列来实现应用程序的解耦合,消息队列相当于是多线程同步队列的扩展版本,不同机器上的应用程序相当于就是线程,而共享的分布式消息队列就是原来程序中的Queue。消息队列(面向消息的中间件)的最流行和最标准化的实现是AMQP(高级消息队列协议),AMQP源于金融行业,提供了排队、路由、可靠传输、安全等功能,最著名的实现包括:Apache的ActiveMQ、RabbitMQ等。 + + 要实现任务的异步化,可以使用名为`Celery`的三方库。`Celery`是Python编写的分布式任务队列,它使用分布式消息进行工作,可以基于RabbitMQ或Redis来作为后端的消息代理。 \ No newline at end of file diff --git a/Day16-20/res/algorithm_complexity_1.png b/Day16-20/res/algorithm_complexity_1.png index 952889d..2d57aed 100644 Binary files a/Day16-20/res/algorithm_complexity_1.png and b/Day16-20/res/algorithm_complexity_1.png differ diff --git a/Day16-20/res/algorithm_complexity_2.png b/Day16-20/res/algorithm_complexity_2.png index 4c14249..0ff66f3 100644 Binary files a/Day16-20/res/algorithm_complexity_2.png and b/Day16-20/res/algorithm_complexity_2.png differ diff --git a/Day21-30/21-30.Web前端概述.md b/Day21-30/21-30.Web前端概述.md index 928da6a..0e4baeb 100644 --- a/Day21-30/21-30.Web前端概述.md +++ b/Day21-30/21-30.Web前端概述.md @@ -1,6 +1,6 @@ ## Web前端概述 -> 说明:本文使用的部分插图来自*Jon Duckett*先生的*[HTML and CSS: Design and Build Websites](https://www.amazon.cn/dp/1118008189/ref=sr_1_5?__mk_zh_CN=%E4%BA%9A%E9%A9%AC%E9%80%8A%E7%BD%91%E7%AB%99&keywords=html+%26+css&qid=1554609325&s=gateway&sr=8-5)*一书,这是一本非常棒的前端入门书,有兴趣的读者可以在亚马逊或者其他网站上找到该书的购买链接。 +> **说明**:本文使用的部分插图来自*Jon Duckett*先生的*[HTML and CSS: Design and Build Websites](https://www.amazon.cn/dp/1118008189/ref=sr_1_5?__mk_zh_CN=%E4%BA%9A%E9%A9%AC%E9%80%8A%E7%BD%91%E7%AB%99&keywords=html+%26+css&qid=1554609325&s=gateway&sr=8-5)*一书,这是一本非常棒的前端入门书,有兴趣的读者可以在亚马逊或者其他网站上找到该书的购买链接。 ### HTML简史 @@ -288,7 +288,7 @@ - `delete`关键字 - 标准对象 - `Number` / `String` / `Boolean` / `Symbol` / `Array` / `Function` - - `Date` / `Error` / `Math` / `RegEx` / `Object` / `Map` / `Set` + - `Date` / `Error` / `Math` / `RegExp` / `Object` / `Map` / `Set` - `JSON` / `Promise` / `Generator` / `Reflect` / `Proxy` #### BOM @@ -903,4 +903,4 @@ Bulma是一个基于Flexbox的现代化的CSS框架,其初衷就是移动优 3. 可视化 - ![](./res/bootstrap-layoutit.png) \ No newline at end of file + ![](./res/bootstrap-layoutit.png) \ No newline at end of file diff --git a/Day21-30/code/list_by_vue.html b/Day21-30/code/list_by_vue.html index 9aaf795..8e94422 100644 --- a/Day21-30/code/list_by_vue.html +++ b/Day21-30/code/list_by_vue.html @@ -68,7 +68,7 @@ </li> </ul> <div> - <input @keydown.enter="addItem()" type="text" id="fname" v-model="fname"> + <input @keydown.enter="addItem()" type="text" id="fname" v-model.trim="fname"> <button id="ok" @click="addItem()">确定</button> </div> </div> @@ -82,8 +82,8 @@ }, methods: { addItem() { - if (this.fname.trim().length > 0) { - this.fruits.push(this.fname.trim()) + if (this.fname.length > 0) { + this.fruits.push(this.fname) } this.fname = '' }, diff --git a/Day21-30/code/new/web1901/images/a1.jpg b/Day21-30/code/new/web1901/images/a1.jpg index eed94cd..b4ce072 100644 Binary files a/Day21-30/code/new/web1901/images/a1.jpg and b/Day21-30/code/new/web1901/images/a1.jpg differ diff --git a/Day21-30/code/new/web1901/images/a2.jpg b/Day21-30/code/new/web1901/images/a2.jpg index dfefd6c..a6be447 100644 Binary files a/Day21-30/code/new/web1901/images/a2.jpg and b/Day21-30/code/new/web1901/images/a2.jpg differ diff --git a/Day21-30/code/new/web1901/images/a3.jpg b/Day21-30/code/new/web1901/images/a3.jpg index 01323ad..4409974 100644 Binary files a/Day21-30/code/new/web1901/images/a3.jpg and b/Day21-30/code/new/web1901/images/a3.jpg differ diff --git a/Day21-30/code/new/web1901/images/backdrop.gif b/Day21-30/code/new/web1901/images/backdrop.gif index fad78a4..0fa15c3 100755 Binary files a/Day21-30/code/new/web1901/images/backdrop.gif and b/Day21-30/code/new/web1901/images/backdrop.gif differ diff --git a/Day21-30/code/new/web1901/images/bird.gif b/Day21-30/code/new/web1901/images/bird.gif index fca6342..8494801 100755 Binary files a/Day21-30/code/new/web1901/images/bird.gif and b/Day21-30/code/new/web1901/images/bird.gif differ diff --git a/Day21-30/code/new/web1901/images/bok-choi.jpg b/Day21-30/code/new/web1901/images/bok-choi.jpg index 04bf15b..5fa8933 100755 Binary files a/Day21-30/code/new/web1901/images/bok-choi.jpg and b/Day21-30/code/new/web1901/images/bok-choi.jpg differ diff --git a/Day21-30/code/new/web1901/images/button-sprite.jpg b/Day21-30/code/new/web1901/images/button-sprite.jpg index 601e9cb..b5e9636 100755 Binary files a/Day21-30/code/new/web1901/images/button-sprite.jpg and b/Day21-30/code/new/web1901/images/button-sprite.jpg differ diff --git a/Day21-30/code/new/web1901/images/buttons.jpg b/Day21-30/code/new/web1901/images/buttons.jpg index d74ad62..8efc830 100755 Binary files a/Day21-30/code/new/web1901/images/buttons.jpg and b/Day21-30/code/new/web1901/images/buttons.jpg differ diff --git a/Day21-30/code/new/web1901/images/chocolate-islands.jpg b/Day21-30/code/new/web1901/images/chocolate-islands.jpg index 8dec94c..36cd69b 100755 Binary files a/Day21-30/code/new/web1901/images/chocolate-islands.jpg and b/Day21-30/code/new/web1901/images/chocolate-islands.jpg differ diff --git a/Day21-30/code/new/web1901/images/clavinet.jpg b/Day21-30/code/new/web1901/images/clavinet.jpg index af722ac..d4078d6 100755 Binary files a/Day21-30/code/new/web1901/images/clavinet.jpg and b/Day21-30/code/new/web1901/images/clavinet.jpg differ diff --git a/Day21-30/code/new/web1901/images/dark-wood.jpg b/Day21-30/code/new/web1901/images/dark-wood.jpg index 1b286a2..33ffe98 100755 Binary files a/Day21-30/code/new/web1901/images/dark-wood.jpg and b/Day21-30/code/new/web1901/images/dark-wood.jpg differ diff --git a/Day21-30/code/new/web1901/images/dots.gif b/Day21-30/code/new/web1901/images/dots.gif index ad94c96..5d40155 100755 Binary files a/Day21-30/code/new/web1901/images/dots.gif and b/Day21-30/code/new/web1901/images/dots.gif differ diff --git a/Day21-30/code/new/web1901/images/email.png b/Day21-30/code/new/web1901/images/email.png index ddc0b45..c258e86 100755 Binary files a/Day21-30/code/new/web1901/images/email.png and b/Day21-30/code/new/web1901/images/email.png differ diff --git a/Day21-30/code/new/web1901/images/header.gif b/Day21-30/code/new/web1901/images/header.gif index abb915b..b2bca3a 100755 Binary files a/Day21-30/code/new/web1901/images/header.gif and b/Day21-30/code/new/web1901/images/header.gif differ diff --git a/Day21-30/code/new/web1901/images/header.jpg b/Day21-30/code/new/web1901/images/header.jpg index 3893500..8da7f65 100755 Binary files a/Day21-30/code/new/web1901/images/header.jpg and b/Day21-30/code/new/web1901/images/header.jpg differ diff --git a/Day21-30/code/new/web1901/images/icon-plus.png b/Day21-30/code/new/web1901/images/icon-plus.png index f046db1..04f15ce 100755 Binary files a/Day21-30/code/new/web1901/images/icon-plus.png and b/Day21-30/code/new/web1901/images/icon-plus.png differ diff --git a/Day21-30/code/new/web1901/images/icon.png b/Day21-30/code/new/web1901/images/icon.png index 0eb1657..ad5889e 100755 Binary files a/Day21-30/code/new/web1901/images/icon.png and b/Day21-30/code/new/web1901/images/icon.png differ diff --git a/Day21-30/code/new/web1901/images/icons.jpg b/Day21-30/code/new/web1901/images/icons.jpg index 32a3758..62cb24c 100644 Binary files a/Day21-30/code/new/web1901/images/icons.jpg and b/Day21-30/code/new/web1901/images/icons.jpg differ diff --git a/Day21-30/code/new/web1901/images/keys.jpg b/Day21-30/code/new/web1901/images/keys.jpg index 4f5f002..da3bc7d 100755 Binary files a/Day21-30/code/new/web1901/images/keys.jpg and b/Day21-30/code/new/web1901/images/keys.jpg differ diff --git a/Day21-30/code/new/web1901/images/lemon-posset.jpg b/Day21-30/code/new/web1901/images/lemon-posset.jpg index c49e1fe..f63ca95 100755 Binary files a/Day21-30/code/new/web1901/images/lemon-posset.jpg and b/Day21-30/code/new/web1901/images/lemon-posset.jpg differ diff --git a/Day21-30/code/new/web1901/images/logo-1.gif b/Day21-30/code/new/web1901/images/logo-1.gif index 4e42c03..1eb753c 100755 Binary files a/Day21-30/code/new/web1901/images/logo-1.gif and b/Day21-30/code/new/web1901/images/logo-1.gif differ diff --git a/Day21-30/code/new/web1901/images/logo-2.gif b/Day21-30/code/new/web1901/images/logo-2.gif index 15de8c1..ecb16ed 100755 Binary files a/Day21-30/code/new/web1901/images/logo-2.gif and b/Day21-30/code/new/web1901/images/logo-2.gif differ diff --git a/Day21-30/code/new/web1901/images/logo-3.gif b/Day21-30/code/new/web1901/images/logo-3.gif index 36c35c5..f80d9bc 100755 Binary files a/Day21-30/code/new/web1901/images/logo-3.gif and b/Day21-30/code/new/web1901/images/logo-3.gif differ diff --git a/Day21-30/code/new/web1901/images/logo.gif b/Day21-30/code/new/web1901/images/logo.gif index 042cce5..46d3e3c 100755 Binary files a/Day21-30/code/new/web1901/images/logo.gif and b/Day21-30/code/new/web1901/images/logo.gif differ diff --git a/Day21-30/code/new/web1901/images/magnolia-large.jpg b/Day21-30/code/new/web1901/images/magnolia-large.jpg index 7a46aa5..ba16630 100755 Binary files a/Day21-30/code/new/web1901/images/magnolia-large.jpg and b/Day21-30/code/new/web1901/images/magnolia-large.jpg differ diff --git a/Day21-30/code/new/web1901/images/magnolia-medium.jpg b/Day21-30/code/new/web1901/images/magnolia-medium.jpg index 1651700..55df446 100755 Binary files a/Day21-30/code/new/web1901/images/magnolia-medium.jpg and b/Day21-30/code/new/web1901/images/magnolia-medium.jpg differ diff --git a/Day21-30/code/new/web1901/images/magnolia-small.jpg b/Day21-30/code/new/web1901/images/magnolia-small.jpg index 85cfed3..7e8a9f9 100755 Binary files a/Day21-30/code/new/web1901/images/magnolia-small.jpg and b/Day21-30/code/new/web1901/images/magnolia-small.jpg differ diff --git a/Day21-30/code/new/web1901/images/otters.jpg b/Day21-30/code/new/web1901/images/otters.jpg index 04ec0a7..cebaafe 100755 Binary files a/Day21-30/code/new/web1901/images/otters.jpg and b/Day21-30/code/new/web1901/images/otters.jpg differ diff --git a/Day21-30/code/new/web1901/images/pattern.gif b/Day21-30/code/new/web1901/images/pattern.gif index b82f9e5..cd24c4c 100755 Binary files a/Day21-30/code/new/web1901/images/pattern.gif and b/Day21-30/code/new/web1901/images/pattern.gif differ diff --git a/Day21-30/code/new/web1901/images/picture-1.jpg b/Day21-30/code/new/web1901/images/picture-1.jpg index 746b8e3..9100e31 100644 Binary files a/Day21-30/code/new/web1901/images/picture-1.jpg and b/Day21-30/code/new/web1901/images/picture-1.jpg differ diff --git a/Day21-30/code/new/web1901/images/picture-2.jpg b/Day21-30/code/new/web1901/images/picture-2.jpg index 506524b..f2194e8 100644 Binary files a/Day21-30/code/new/web1901/images/picture-2.jpg and b/Day21-30/code/new/web1901/images/picture-2.jpg differ diff --git a/Day21-30/code/new/web1901/images/picture-3.jpg b/Day21-30/code/new/web1901/images/picture-3.jpg index 4533c43..9489dd0 100644 Binary files a/Day21-30/code/new/web1901/images/picture-3.jpg and b/Day21-30/code/new/web1901/images/picture-3.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-01.jpg b/Day21-30/code/new/web1901/images/print-01.jpg index 94f2d69..be5242d 100755 Binary files a/Day21-30/code/new/web1901/images/print-01.jpg and b/Day21-30/code/new/web1901/images/print-01.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-02.jpg b/Day21-30/code/new/web1901/images/print-02.jpg index 1a5ef16..84648ce 100755 Binary files a/Day21-30/code/new/web1901/images/print-02.jpg and b/Day21-30/code/new/web1901/images/print-02.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-03.jpg b/Day21-30/code/new/web1901/images/print-03.jpg index 2aa84e5..1c10aba 100755 Binary files a/Day21-30/code/new/web1901/images/print-03.jpg and b/Day21-30/code/new/web1901/images/print-03.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-04.jpg b/Day21-30/code/new/web1901/images/print-04.jpg index 3550b91..e28fcba 100755 Binary files a/Day21-30/code/new/web1901/images/print-04.jpg and b/Day21-30/code/new/web1901/images/print-04.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-05.jpg b/Day21-30/code/new/web1901/images/print-05.jpg index 121685c..d23c32b 100755 Binary files a/Day21-30/code/new/web1901/images/print-05.jpg and b/Day21-30/code/new/web1901/images/print-05.jpg differ diff --git a/Day21-30/code/new/web1901/images/print-06.jpg b/Day21-30/code/new/web1901/images/print-06.jpg index 118783a..6ff6ccb 100755 Binary files a/Day21-30/code/new/web1901/images/print-06.jpg and b/Day21-30/code/new/web1901/images/print-06.jpg differ diff --git a/Day21-30/code/new/web1901/images/puppy.jpg b/Day21-30/code/new/web1901/images/puppy.jpg index 3f1933c..abea7c3 100755 Binary files a/Day21-30/code/new/web1901/images/puppy.jpg and b/Day21-30/code/new/web1901/images/puppy.jpg differ diff --git a/Day21-30/code/new/web1901/images/python-logo.png b/Day21-30/code/new/web1901/images/python-logo.png index e6c63e1..68ef60f 100644 Binary files a/Day21-30/code/new/web1901/images/python-logo.png and b/Day21-30/code/new/web1901/images/python-logo.png differ diff --git a/Day21-30/code/new/web1901/images/quokka.jpg b/Day21-30/code/new/web1901/images/quokka.jpg index 7d11e11..a7d801c 100755 Binary files a/Day21-30/code/new/web1901/images/quokka.jpg and b/Day21-30/code/new/web1901/images/quokka.jpg differ diff --git a/Day21-30/code/new/web1901/images/rhodes.jpg b/Day21-30/code/new/web1901/images/rhodes.jpg index 4ad1489..4d5dc69 100755 Binary files a/Day21-30/code/new/web1901/images/rhodes.jpg and b/Day21-30/code/new/web1901/images/rhodes.jpg differ diff --git a/Day21-30/code/new/web1901/images/roasted-brussel-sprouts.jpg b/Day21-30/code/new/web1901/images/roasted-brussel-sprouts.jpg index 87b08c4..e95dae4 100755 Binary files a/Day21-30/code/new/web1901/images/roasted-brussel-sprouts.jpg and b/Day21-30/code/new/web1901/images/roasted-brussel-sprouts.jpg differ diff --git a/Day21-30/code/new/web1901/images/shadow.png b/Day21-30/code/new/web1901/images/shadow.png index 6d136cc..98ce05f 100755 Binary files a/Day21-30/code/new/web1901/images/shadow.png and b/Day21-30/code/new/web1901/images/shadow.png differ diff --git a/Day21-30/code/new/web1901/images/slide-1.jpg b/Day21-30/code/new/web1901/images/slide-1.jpg index 1437467..6dc6a85 100644 Binary files a/Day21-30/code/new/web1901/images/slide-1.jpg and b/Day21-30/code/new/web1901/images/slide-1.jpg differ diff --git a/Day21-30/code/new/web1901/images/slide-2.jpg b/Day21-30/code/new/web1901/images/slide-2.jpg index ffd8b43..a631b87 100644 Binary files a/Day21-30/code/new/web1901/images/slide-2.jpg and b/Day21-30/code/new/web1901/images/slide-2.jpg differ diff --git a/Day21-30/code/new/web1901/images/slide-3.jpg b/Day21-30/code/new/web1901/images/slide-3.jpg index 46bd9c5..4fa7315 100644 Binary files a/Day21-30/code/new/web1901/images/slide-3.jpg and b/Day21-30/code/new/web1901/images/slide-3.jpg differ diff --git a/Day21-30/code/new/web1901/images/slide-4.jpg b/Day21-30/code/new/web1901/images/slide-4.jpg index d226070..7823552 100644 Binary files a/Day21-30/code/new/web1901/images/slide-4.jpg and b/Day21-30/code/new/web1901/images/slide-4.jpg differ diff --git a/Day21-30/code/new/web1901/images/star.png b/Day21-30/code/new/web1901/images/star.png index 3c1bcdc..9c88493 100755 Binary files a/Day21-30/code/new/web1901/images/star.png and b/Day21-30/code/new/web1901/images/star.png differ diff --git a/Day21-30/code/new/web1901/images/subscribe.jpg b/Day21-30/code/new/web1901/images/subscribe.jpg index 9530ce5..ef7dabd 100755 Binary files a/Day21-30/code/new/web1901/images/subscribe.jpg and b/Day21-30/code/new/web1901/images/subscribe.jpg differ diff --git a/Day21-30/code/new/web1901/images/teriyaki.jpg b/Day21-30/code/new/web1901/images/teriyaki.jpg index 46ef115..f8bac47 100755 Binary files a/Day21-30/code/new/web1901/images/teriyaki.jpg and b/Day21-30/code/new/web1901/images/teriyaki.jpg differ diff --git a/Day21-30/code/new/web1901/images/thumb-1.jpg b/Day21-30/code/new/web1901/images/thumb-1.jpg index 2588658..5fc58b7 100644 Binary files a/Day21-30/code/new/web1901/images/thumb-1.jpg and b/Day21-30/code/new/web1901/images/thumb-1.jpg differ diff --git a/Day21-30/code/new/web1901/images/thumb-2.jpg b/Day21-30/code/new/web1901/images/thumb-2.jpg index aa714c5..54c1821 100644 Binary files a/Day21-30/code/new/web1901/images/thumb-2.jpg and b/Day21-30/code/new/web1901/images/thumb-2.jpg differ diff --git a/Day21-30/code/new/web1901/images/thumb-3.jpg b/Day21-30/code/new/web1901/images/thumb-3.jpg index 07db678..b787e42 100644 Binary files a/Day21-30/code/new/web1901/images/thumb-3.jpg and b/Day21-30/code/new/web1901/images/thumb-3.jpg differ diff --git a/Day21-30/code/new/web1901/images/tim.png b/Day21-30/code/new/web1901/images/tim.png index 72555ae..00ef80e 100644 Binary files a/Day21-30/code/new/web1901/images/tim.png and b/Day21-30/code/new/web1901/images/tim.png differ diff --git a/Day21-30/code/new/web1901/images/title.gif b/Day21-30/code/new/web1901/images/title.gif index 69bd450..8b3fd41 100755 Binary files a/Day21-30/code/new/web1901/images/title.gif and b/Day21-30/code/new/web1901/images/title.gif differ diff --git a/Day21-30/code/new/web1901/images/tulip.gif b/Day21-30/code/new/web1901/images/tulip.gif index 9c4b6a2..ebae83c 100755 Binary files a/Day21-30/code/new/web1901/images/tulip.gif and b/Day21-30/code/new/web1901/images/tulip.gif differ diff --git a/Day21-30/code/new/web1901/images/twitter.png b/Day21-30/code/new/web1901/images/twitter.png index e1d44bb..6a7ad51 100755 Binary files a/Day21-30/code/new/web1901/images/twitter.png and b/Day21-30/code/new/web1901/images/twitter.png differ diff --git a/Day21-30/code/new/web1901/images/web.png b/Day21-30/code/new/web1901/images/web.png index 5b81857..b0c5f40 100755 Binary files a/Day21-30/code/new/web1901/images/web.png and b/Day21-30/code/new/web1901/images/web.png differ diff --git a/Day21-30/code/new/web1901/images/wurlitzer.jpg b/Day21-30/code/new/web1901/images/wurlitzer.jpg index 32370a5..971c218 100755 Binary files a/Day21-30/code/new/web1901/images/wurlitzer.jpg and b/Day21-30/code/new/web1901/images/wurlitzer.jpg differ diff --git a/Day21-30/code/new/web1901/images/zucchini-cake.jpg b/Day21-30/code/new/web1901/images/zucchini-cake.jpg index 7072601..2788a0a 100755 Binary files a/Day21-30/code/new/web1901/images/zucchini-cake.jpg and b/Day21-30/code/new/web1901/images/zucchini-cake.jpg differ diff --git a/Day21-30/code/old/html+css/example.html b/Day21-30/code/old/html+css/example.html index ae77ce5..1ffdc31 100644 --- a/Day21-30/code/old/html+css/example.html +++ b/Day21-30/code/old/html+css/example.html @@ -1,80 +1,80 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="UTF-8"> - <title> - - - - - - + + + + + + + + + + + diff --git a/Day21-30/code/old/javascript/img/a1.jpg b/Day21-30/code/old/javascript/img/a1.jpg index eed94cd..b4ce072 100644 Binary files a/Day21-30/code/old/javascript/img/a1.jpg and b/Day21-30/code/old/javascript/img/a1.jpg differ diff --git a/Day21-30/code/old/javascript/img/a2.jpg b/Day21-30/code/old/javascript/img/a2.jpg index dfefd6c..a6be447 100644 Binary files a/Day21-30/code/old/javascript/img/a2.jpg and b/Day21-30/code/old/javascript/img/a2.jpg differ diff --git a/Day21-30/code/old/javascript/img/a3.jpg b/Day21-30/code/old/javascript/img/a3.jpg index 01323ad..4409974 100644 Binary files a/Day21-30/code/old/javascript/img/a3.jpg and b/Day21-30/code/old/javascript/img/a3.jpg differ diff --git a/Day21-30/code/old/javascript/img/picture-1.jpg b/Day21-30/code/old/javascript/img/picture-1.jpg index 746b8e3..9100e31 100644 Binary files a/Day21-30/code/old/javascript/img/picture-1.jpg and b/Day21-30/code/old/javascript/img/picture-1.jpg differ diff --git a/Day21-30/code/old/javascript/img/picture-2.jpg b/Day21-30/code/old/javascript/img/picture-2.jpg index 506524b..f2194e8 100644 Binary files a/Day21-30/code/old/javascript/img/picture-2.jpg and b/Day21-30/code/old/javascript/img/picture-2.jpg differ diff --git a/Day21-30/code/old/javascript/img/picture-3.jpg b/Day21-30/code/old/javascript/img/picture-3.jpg index 4533c43..9489dd0 100644 Binary files a/Day21-30/code/old/javascript/img/picture-3.jpg and b/Day21-30/code/old/javascript/img/picture-3.jpg differ diff --git a/Day21-30/code/old/javascript/img/slide-1.jpg b/Day21-30/code/old/javascript/img/slide-1.jpg index 1437467..6dc6a85 100644 Binary files a/Day21-30/code/old/javascript/img/slide-1.jpg and b/Day21-30/code/old/javascript/img/slide-1.jpg differ diff --git a/Day21-30/code/old/javascript/img/slide-2.jpg b/Day21-30/code/old/javascript/img/slide-2.jpg index ffd8b43..a631b87 100644 Binary files a/Day21-30/code/old/javascript/img/slide-2.jpg and b/Day21-30/code/old/javascript/img/slide-2.jpg differ diff --git a/Day21-30/code/old/javascript/img/slide-3.jpg b/Day21-30/code/old/javascript/img/slide-3.jpg index 46bd9c5..4fa7315 100644 Binary files a/Day21-30/code/old/javascript/img/slide-3.jpg and b/Day21-30/code/old/javascript/img/slide-3.jpg differ diff --git a/Day21-30/code/old/javascript/img/slide-4.jpg b/Day21-30/code/old/javascript/img/slide-4.jpg index d226070..7823552 100644 Binary files a/Day21-30/code/old/javascript/img/slide-4.jpg and b/Day21-30/code/old/javascript/img/slide-4.jpg differ diff --git a/Day21-30/code/old/javascript/img/thumb-1.jpg b/Day21-30/code/old/javascript/img/thumb-1.jpg index 2588658..5fc58b7 100644 Binary files a/Day21-30/code/old/javascript/img/thumb-1.jpg and b/Day21-30/code/old/javascript/img/thumb-1.jpg differ diff --git a/Day21-30/code/old/javascript/img/thumb-2.jpg b/Day21-30/code/old/javascript/img/thumb-2.jpg index aa714c5..54c1821 100644 Binary files a/Day21-30/code/old/javascript/img/thumb-2.jpg and b/Day21-30/code/old/javascript/img/thumb-2.jpg differ diff --git a/Day21-30/code/old/javascript/img/thumb-3.jpg b/Day21-30/code/old/javascript/img/thumb-3.jpg index 07db678..b787e42 100644 Binary files a/Day21-30/code/old/javascript/img/thumb-3.jpg and b/Day21-30/code/old/javascript/img/thumb-3.jpg differ diff --git a/Day21-30/code/垃圾分类查询/harmful-waste.png b/Day21-30/code/垃圾分类查询/harmful-waste.png deleted file mode 100644 index edaff8b..0000000 Binary files a/Day21-30/code/垃圾分类查询/harmful-waste.png and /dev/null differ diff --git a/Day21-30/code/垃圾分类查询/images/harmful-waste.png b/Day21-30/code/垃圾分类查询/images/harmful-waste.png new file mode 100644 index 0000000..2055de5 Binary files /dev/null and b/Day21-30/code/垃圾分类查询/images/harmful-waste.png differ diff --git a/Day21-30/code/垃圾分类查询/images/kitchen-waste.png b/Day21-30/code/垃圾分类查询/images/kitchen-waste.png new file mode 100644 index 0000000..542bd28 Binary files /dev/null and b/Day21-30/code/垃圾分类查询/images/kitchen-waste.png differ diff --git a/Day21-30/code/垃圾分类查询/images/other-waste.png b/Day21-30/code/垃圾分类查询/images/other-waste.png new file mode 100644 index 0000000..7bf4463 Binary files /dev/null and b/Day21-30/code/垃圾分类查询/images/other-waste.png differ diff --git a/Day21-30/code/垃圾分类查询/images/recyclable.png b/Day21-30/code/垃圾分类查询/images/recyclable.png new file mode 100644 index 0000000..fbf35cc Binary files /dev/null and b/Day21-30/code/垃圾分类查询/images/recyclable.png differ diff --git a/Day21-30/code/垃圾分类查询/垃圾分类.html b/Day21-30/code/垃圾分类查询/index.html similarity index 94% rename from Day21-30/code/垃圾分类查询/垃圾分类.html rename to Day21-30/code/垃圾分类查询/index.html index 5191864..e2596c3 100644 --- a/Day21-30/code/垃圾分类查询/垃圾分类.html +++ b/Day21-30/code/垃圾分类查询/index.html @@ -65,7 +65,7 @@ @@ -75,9 +75,9 @@

- +    - + {{ result.name }}    (预测结果) @@ -102,7 +102,7 @@ // 查询垃圾分类的函数 search() { if (this.word.trim().length > 0) { - let key = '9aeb28ee8858a167c1755f856f830e22' + let key = '9636cec76ee2593ba6b195e5b770b394' let url = `http://api.tianapi.com/txapi/lajifenlei/?key=${key}&word=${this.word}` fetch(url) .then(resp => resp.json()) diff --git a/Day21-30/code/垃圾分类查询/kitchen-waste.png b/Day21-30/code/垃圾分类查询/kitchen-waste.png deleted file mode 100644 index cd52f47..0000000 Binary files a/Day21-30/code/垃圾分类查询/kitchen-waste.png and /dev/null differ diff --git a/Day21-30/code/垃圾分类查询/other-waste.png b/Day21-30/code/垃圾分类查询/other-waste.png deleted file mode 100644 index ef2222b..0000000 Binary files a/Day21-30/code/垃圾分类查询/other-waste.png and /dev/null differ diff --git a/Day21-30/code/垃圾分类查询/recyclable.png b/Day21-30/code/垃圾分类查询/recyclable.png deleted file mode 100644 index a82922f..0000000 Binary files a/Day21-30/code/垃圾分类查询/recyclable.png and /dev/null differ diff --git a/Day21-30/res/baidu_echarts.png b/Day21-30/res/baidu_echarts.png index e583e89..48ff43c 100644 Binary files a/Day21-30/res/baidu_echarts.png and b/Day21-30/res/baidu_echarts.png differ diff --git a/Day21-30/res/bootstrap-layoutit.png b/Day21-30/res/bootstrap-layoutit.png index ae39347..3735ac8 100644 Binary files a/Day21-30/res/bootstrap-layoutit.png and b/Day21-30/res/bootstrap-layoutit.png differ diff --git a/Day21-30/res/browser-joke-1.png b/Day21-30/res/browser-joke-1.png deleted file mode 100644 index 0e3efd8..0000000 Binary files a/Day21-30/res/browser-joke-1.png and /dev/null differ diff --git a/Day21-30/res/browser-joke-2.png b/Day21-30/res/browser-joke-2.png deleted file mode 100644 index b3ae531..0000000 Binary files a/Day21-30/res/browser-joke-2.png and /dev/null differ diff --git a/Day21-30/res/browser-joke-3.png b/Day21-30/res/browser-joke-3.png deleted file mode 100644 index bd6028f..0000000 Binary files a/Day21-30/res/browser-joke-3.png and /dev/null differ diff --git a/Day21-30/res/dom-page.png b/Day21-30/res/dom-page.png deleted file mode 100644 index 2777e9c..0000000 Binary files a/Day21-30/res/dom-page.png and /dev/null differ diff --git a/Day21-30/res/dom-tree.png b/Day21-30/res/dom-tree.png deleted file mode 100644 index ce5e74e..0000000 Binary files a/Day21-30/res/dom-tree.png and /dev/null differ diff --git a/Day21-30/res/字体样式.png b/Day21-30/res/字体样式.png index 9baacb6..8f592bb 100644 Binary files a/Day21-30/res/字体样式.png and b/Day21-30/res/字体样式.png differ diff --git a/Day21-30/res/字符实体.png b/Day21-30/res/字符实体.png index 4a1fd12..dd18622 100644 Binary files a/Day21-30/res/字符实体.png and b/Day21-30/res/字符实体.png differ diff --git a/Day21-30/res/客户端对字体文件的支持.png b/Day21-30/res/客户端对字体文件的支持.png index aa93eeb..1a0e5b0 100644 Binary files a/Day21-30/res/客户端对字体文件的支持.png and b/Day21-30/res/客户端对字体文件的支持.png differ diff --git a/Day21-30/res/尺寸单位.png b/Day21-30/res/尺寸单位.png index 3b71674..845e32b 100644 Binary files a/Day21-30/res/尺寸单位.png and b/Day21-30/res/尺寸单位.png differ diff --git a/Day21-30/res/属性选择器.png b/Day21-30/res/属性选择器.png index f6ae4dc..06fef27 100644 Binary files a/Day21-30/res/属性选择器.png and b/Day21-30/res/属性选择器.png differ diff --git a/Day21-30/res/常用选择器.png b/Day21-30/res/常用选择器.png index bf86166..a54f4de 100644 Binary files a/Day21-30/res/常用选择器.png and b/Day21-30/res/常用选择器.png differ diff --git a/Day21-30/res/开始标签.png b/Day21-30/res/开始标签.png index 29bd455..6f79eb4 100644 Binary files a/Day21-30/res/开始标签.png and b/Day21-30/res/开始标签.png differ diff --git a/Day21-30/res/标签属性.png b/Day21-30/res/标签属性.png index 21eb12f..7eb42f0 100644 Binary files a/Day21-30/res/标签属性.png and b/Day21-30/res/标签属性.png differ diff --git a/Day21-30/res/样式属性.png b/Day21-30/res/样式属性.png index 476ef50..9b63b89 100644 Binary files a/Day21-30/res/样式属性.png and b/Day21-30/res/样式属性.png differ diff --git a/Day21-30/res/盒子模型.png b/Day21-30/res/盒子模型.png index a2517f3..af181ff 100644 Binary files a/Day21-30/res/盒子模型.png and b/Day21-30/res/盒子模型.png differ diff --git a/Day21-30/res/相对路径.png b/Day21-30/res/相对路径.png index b0e6ec9..f9b75ff 100644 Binary files a/Day21-30/res/相对路径.png and b/Day21-30/res/相对路径.png differ diff --git a/Day21-30/res/经典布局-1.png b/Day21-30/res/经典布局-1.png index 42f4b94..16dfe2b 100644 Binary files a/Day21-30/res/经典布局-1.png and b/Day21-30/res/经典布局-1.png differ diff --git a/Day21-30/res/经典布局-2.png b/Day21-30/res/经典布局-2.png index 089133b..349c6d0 100644 Binary files a/Day21-30/res/经典布局-2.png and b/Day21-30/res/经典布局-2.png differ diff --git a/Day21-30/res/结束标签.png b/Day21-30/res/结束标签.png index c80a3c2..8034aa3 100644 Binary files a/Day21-30/res/结束标签.png and b/Day21-30/res/结束标签.png differ diff --git a/Day21-30/res/网站地图.png b/Day21-30/res/网站地图.png index 55a4daf..744e7d9 100644 Binary files a/Day21-30/res/网站地图.png and b/Day21-30/res/网站地图.png differ diff --git a/Day21-30/res/衬线字体+非衬线字体+等宽字体.png b/Day21-30/res/衬线字体+非衬线字体+等宽字体.png index 7693210..1fd0818 100644 Binary files a/Day21-30/res/衬线字体+非衬线字体+等宽字体.png and b/Day21-30/res/衬线字体+非衬线字体+等宽字体.png differ diff --git a/Day21-30/res/选择器语法.png b/Day21-30/res/选择器语法.png index 54c159d..75021ef 100644 Binary files a/Day21-30/res/选择器语法.png and b/Day21-30/res/选择器语法.png differ diff --git a/Day31-35/31-35.玩转Linux操作系统.md b/Day31-35/31-35.玩转Linux操作系统.md index c519043..ea59ac0 100644 --- a/Day31-35/31-35.玩转Linux操作系统.md +++ b/Day31-35/31-35.玩转Linux操作系统.md @@ -1,6 +1,6 @@ ## 玩转Linux操作系统 -> 说明:本文中对Linux命令的讲解都是基于名为CentOS的Linux发行版本,我自己使用的是阿里云服务器,系统版本为CentOS Linux release 7.6.1810。不同的Linux发行版本在Shell命令和工具程序上会有一些差别,但是这些差别是很小的。 +> **说明**:本文中对Linux命令的讲解都是基于名为CentOS的Linux发行版本,我自己使用的是阿里云服务器,系统版本为CentOS Linux release 7.6.1810。不同的Linux发行版本在Shell命令和工具程序上会有一些差别,但是这些差别是很小的。 ### 操作系统发展史 @@ -111,7 +111,7 @@ Linux系统的命令通常都是如下所示的格式: Shell也被称为“壳”或“壳程序”,它是用户与操作系统内核交流的翻译官,简单的说就是人与计算机交互的界面和接口。目前很多Linux系统默认的Shell都是bash(Bourne Again SHell),因为它可以使用tab键进行命令和路径补全、可以保存历史命令、可以方便的配置环境变量以及执行批处理操作。 ```Shell - [root@izwz97tbgo9lkabnat2lo8z ~]# ps + [root ~]# ps PID TTY TIME CMD 3531 pts/0 00:00:00 bash 3553 pts/0 00:00:00 ps @@ -136,7 +136,7 @@ Linux系统的命令通常都是如下所示的格式: 4. 清除屏幕上显示的内容 - **clear**。 -5. 查看帮助文档 - **man** / **info** / **help** / **apropos**。 +5. 查看帮助文档 - **man** / **info** / **--help** / **apropos**。 ```Shell [root@izwz97tbgo9lkabnat2lo8z ~]# ps --help Usage: @@ -230,7 +230,7 @@ Linux系统的命令通常都是如下所示的格式: [root@iZwz97tbgo9lkabnat2lo8Z ~]# !454 ``` - > 说明:查看到历史命令之后,可以用`!历史命令编号`来重新执行该命令;通过`history -c`可以清除历史命令。 + > **说明**:查看到历史命令之后,可以用`!历史命令编号`来重新执行该命令;通过`history -c`可以清除历史命令。 ### 实用程序 @@ -308,7 +308,7 @@ Linux系统的命令通常都是如下所示的格式: ... ``` - > 说明:上面用到了一个名为`wget`的命令,它是一个网络下载器程序,可以从指定的URL下载资源。 + > **说明**:上面用到了一个名为`wget`的命令,它是一个网络下载器程序,可以从指定的URL下载资源。 6. 拷贝/移动文件 - **cp** / **mv**。 @@ -350,7 +350,7 @@ Linux系统的命令通常都是如下所示的格式: 52: ... ``` - > 说明:`grep`在搜索字符串时可以使用正则表达式,如果需要使用正则表达式可以用`grep -E`或者直接使用`egrep`。 + > **说明**:`grep`在搜索字符串时可以使用正则表达式,如果需要使用正则表达式可以用`grep -E`或者直接使用`egrep`。 9. 创建链接和查看链接 - **ln** / **readlink**。 @@ -372,7 +372,7 @@ Linux系统的命令通常都是如下所示的格式: CentOS Linux release 7.4.1708 (Core) ``` - > 说明:链接可以分为硬链接和软链接(符号链接)。硬链接可以认为是一个指向文件数据的指针,就像Python中对象的引用计数,每添加一个硬链接,文件的对应链接数就增加1,只有当文件的链接数为0时,文件所对应的存储空间才有可能被其他文件覆盖。我们平常删除文件时其实并没有删除硬盘上的数据,我们删除的只是一个指针,或者说是数据的一条使用记录,所以类似于“文件粉碎机”之类的软件在“粉碎”文件时除了删除文件指针,还会在文件对应的存储区域填入数据来保证文件无法再恢复。软链接类似于Windows系统下的快捷方式,当软链接链接的文件被删除时,软链接也就失效了。 + > **说明**:链接可以分为硬链接和软链接(符号链接)。硬链接可以认为是一个指向文件数据的指针,就像Python中对象的引用计数,每添加一个硬链接,文件的对应链接数就增加1,只有当文件的链接数为0时,文件所对应的存储空间才有可能被其他文件覆盖。我们平常删除文件时其实并没有删除硬盘上的数据,我们删除的只是一个指针,或者说是数据的一条使用记录,所以类似于“文件粉碎机”之类的软件在“粉碎”文件时除了删除文件指针,还会在文件对应的存储区域填入数据来保证文件无法再恢复。软链接类似于Windows系统下的快捷方式,当软链接链接的文件被删除时,软链接也就失效了。 10. 压缩/解压缩和归档/解归档 - **gzip** / **gunzip** / **xz**。 @@ -429,7 +429,7 @@ Linux系统的命令通常都是如下所示的格式: [root@iZwz97tbgo9lkabnat2lo8Z ~]# xargs < a.txt > b.txt ``` - > 说明:这个命令就像上面演示的那样常在管道(实现进程间通信的一种方式)和重定向(重新指定输入输出的位置)操作中用到,后面的内容中会讲到管道操作和输入输出重定向操作。 + > **说明**:这个命令就像上面演示的那样常在管道(实现进程间通信的一种方式)和重定向(重新指定输入输出的位置)操作中用到,后面的内容中会讲到管道操作和输入输出重定向操作。 13. 显示文件或目录 - **basename** / **dirname**。 @@ -1283,7 +1283,7 @@ build environment: ### 计划任务 -1. 在指定的时间执行命令 +1. 在指定的时间执行命令。 - **at** - 将任务排队,在指定的时间执行。 - **atq** - 查看待执行的任务队列。 @@ -1788,6 +1788,8 @@ echo '结果: '$sum ```Shell #!/usr/bin/bash +printf '输入文件夹名: ' +read dir printf '输入文件名: ' read file printf '输入文件数量(<1000): ' diff --git a/Day31-35/res/andrew.jpg b/Day31-35/res/andrew.jpg index 8f001d3..41f37a5 100644 Binary files a/Day31-35/res/andrew.jpg and b/Day31-35/res/andrew.jpg differ diff --git a/Day31-35/res/dmr.png b/Day31-35/res/dmr.png index 2453340..2ca20e8 100644 Binary files a/Day31-35/res/dmr.png and b/Day31-35/res/dmr.png differ diff --git a/Day31-35/res/file-mode.png b/Day31-35/res/file-mode.png index 294139a..f80d500 100644 Binary files a/Day31-35/res/file-mode.png and b/Day31-35/res/file-mode.png differ diff --git a/Day31-35/res/history-of-os.png b/Day31-35/res/history-of-os.png deleted file mode 100644 index 22262ec..0000000 Binary files a/Day31-35/res/history-of-os.png and /dev/null differ diff --git a/Day31-35/res/history-of-unix.png b/Day31-35/res/history-of-unix.png index 401b706..1da969e 100644 Binary files a/Day31-35/res/history-of-unix.png and b/Day31-35/res/history-of-unix.png differ diff --git a/Day31-35/res/ibm-col80-punched-card.png b/Day31-35/res/ibm-col80-punched-card.png index 467ce12..8a797b1 100644 Binary files a/Day31-35/res/ibm-col80-punched-card.png and b/Day31-35/res/ibm-col80-punched-card.png differ diff --git a/Day31-35/res/ken-and-dennis-pdp-11.png b/Day31-35/res/ken-and-dennis-pdp-11.png index 28ad0f7..2a2b510 100644 Binary files a/Day31-35/res/ken-and-dennis-pdp-11.png and b/Day31-35/res/ken-and-dennis-pdp-11.png differ diff --git a/Day31-35/res/ken_old.png b/Day31-35/res/ken_old.png index 5d322c4..7fd7853 100644 Binary files a/Day31-35/res/ken_old.png and b/Day31-35/res/ken_old.png differ diff --git a/Day31-35/res/ken_young.jpg b/Day31-35/res/ken_young.jpg index 46e3009..4bf8fa6 100644 Binary files a/Day31-35/res/ken_young.jpg and b/Day31-35/res/ken_young.jpg differ diff --git a/Day31-35/res/linus.png b/Day31-35/res/linus.png index acbe3bf..b2e1620 100644 Binary files a/Day31-35/res/linus.png and b/Day31-35/res/linus.png differ diff --git a/Day31-35/res/linux-network-config.png b/Day31-35/res/linux-network-config.png index a3b01e6..1db952c 100644 Binary files a/Day31-35/res/linux-network-config.png and b/Day31-35/res/linux-network-config.png differ diff --git a/Day31-35/res/pdp-11.jpg b/Day31-35/res/pdp-11.jpg index 6b4486b..13cca8e 100644 Binary files a/Day31-35/res/pdp-11.jpg and b/Day31-35/res/pdp-11.jpg differ diff --git a/Day31-35/res/pdp-7.png b/Day31-35/res/pdp-7.png index 8e7ab9e..8246dd0 100644 Binary files a/Day31-35/res/pdp-7.png and b/Day31-35/res/pdp-7.png differ diff --git a/Day31-35/res/vim-diff.png b/Day31-35/res/vim-diff.png index 5fde982..5951e02 100644 Binary files a/Day31-35/res/vim-diff.png and b/Day31-35/res/vim-diff.png differ diff --git a/Day31-35/res/vim-macro.png b/Day31-35/res/vim-macro.png index 33b5eed..e80ef3e 100644 Binary files a/Day31-35/res/vim-macro.png and b/Day31-35/res/vim-macro.png differ diff --git a/Day31-35/res/vim-multi-window.png b/Day31-35/res/vim-multi-window.png index c6e17d7..5028d27 100644 Binary files a/Day31-35/res/vim-multi-window.png and b/Day31-35/res/vim-multi-window.png differ diff --git a/Day36-40/36-38.关系型数据库MySQL.md b/Day36-40/36-38.关系型数据库MySQL.md index 50e78d5..8b2b48d 100644 --- a/Day36-40/36-38.关系型数据库MySQL.md +++ b/Day36-40/36-38.关系型数据库MySQL.md @@ -74,6 +74,8 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 ```Shell rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm + rpm -ivh mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm + rpm -ivh mysql-community-devel-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm ``` @@ -174,7 +176,7 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 alter user 'root'@'localhost' identified by '123456'; ``` - > 说明:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。 + > **说明**:MySQL较新的版本默认不允许使用弱口令作为用户口令,所以我们通过上面的前两条命令修改了验证用户口令的策略和口令的长度。事实上我们不应该使用弱口令,因为存在用户口令被暴力破解的风险。近年来,攻击数据库窃取数据和劫持数据库勒索比特币的事件屡见不鲜,要避免这些潜在的风险,最为重要的一点是不要让数据库服务器暴露在公网上(最好的做法是将数据库置于内网,至少要做到不向公网开放数据库服务器的访问端口),另外要保管好`root`账号的口令,应用系统需要访问数据库时,通常不使用`root`账号进行访问,而是创建其他拥有适当权限的账号来访问。 再次使用客户端工具连接MySQL服务器时,就可以使用新设置的口令了。在实际开发中,为了方便用户操作,可以选择图形化的客户端工具来连接MySQL服务器,包括: @@ -243,21 +245,21 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 -- 创建学院表 create table tb_college ( - collid int auto_increment comment '编号', - collname varchar(50) not null comment '名称', - intro varchar(500) default '' comment '介绍', + collid int auto_increment comment '编号', + collname varchar(50) not null comment '名称', + collintro varchar(500) default '' comment '介绍', primary key (collid) ); -- 创建学生表 create table tb_student ( - stuid int not null comment '学号', - stuname varchar(20) not null comment '姓名', - sex boolean default 1 comment '性别', - birth date not null comment '出生日期', - addr varchar(255) default '' comment '籍贯', - collid int not null comment '所属学院', + stuid int not null comment '学号', + stuname varchar(20) not null comment '姓名', + stusex boolean default 1 comment '性别', + stubirth date not null comment '出生日期', + stuaddr varchar(255) default '' comment '籍贯', + collid int not null comment '所属学院', primary key (stuid), foreign key (collid) references tb_college (collid) ); @@ -265,10 +267,10 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 -- 创建教师表 create table tb_teacher ( - teaid int not null comment '工号', - teaname varchar(20) not null comment '姓名', - title varchar(10) default '助教' comment '职称', - collid int not null comment '所属学院', + teaid int not null comment '工号', + teaname varchar(20) not null comment '姓名', + teatitle varchar(10) default '助教' comment '职称', + collid int not null comment '所属学院', primary key (teaid), foreign key (collid) references tb_college (collid) ); @@ -276,10 +278,10 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 -- 创建课程表 create table tb_course ( - couid int not null comment '编号', - couname varchar(50) not null comment '名称', - credit int not null comment '学分', - teaid int not null comment '授课老师', + couid int not null comment '编号', + couname varchar(50) not null comment '名称', + coucredit int not null comment '学分', + teaid int not null comment '授课老师', primary key (couid), foreign key (teaid) references tb_teacher (teaid) ); @@ -287,11 +289,11 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 -- 创建选课记录表 create table tb_record ( - recid int auto_increment comment '选课记录编号', - sid int not null comment '选课学生', - cid int not null comment '所选课程', - seldate datetime default now() comment '选课时间日期', - score decimal(4,1) comment '考试成绩', + recid int auto_increment comment '选课记录编号', + sid int not null comment '选课学生', + cid int not null comment '所选课程', + seldate datetime default now() comment '选课时间日期', + score decimal(4,1) comment '考试成绩', primary key (recid), foreign key (sid) references tb_student (stuid), foreign key (cid) references tb_course (couid), @@ -548,13 +550,13 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 ```SQL -- 插入学院数据 - insert into tb_college (collname, intro) values - ('计算机学院', '创建于1956年是我国首批建立计算机专业。学院现有计算机科学与技术一级学科和网络空间安全一级学科博士学位授予权,其中计算机科学与技术一级学科具有博士后流动站。计算机科学与技术一级学科在2017年全国第四轮学科评估中评为A;2019 U.S.News全球计算机学科排名26名;ESI学科排名0.945‰,进入全球前1‰,位列第43位。'), - ('外国语学院', '1998年浙江大学、杭州大学、浙江农业大学、浙江医科大学四校合并,成立新的浙江大学。1999年原浙江大学外语系、原杭州大学外国语学院、原杭州大学大外部、原浙江农业大学公外部、原浙江医科大学外语教学部合并,成立浙江大学外国语学院。2003年学院更名为浙江大学外国语言文化与国际交流学院。'), - ('经济管理学院', '四川大学经济学院历史悠久、传承厚重,其前身是创办于1905年的四川大学经济科,距今已有100多年的历史。已故著名经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代著名学者刘诗白等曾先后在此任教或学习。在长期的办学过程中,学院坚持以马克思主义的立场、观点、方法为指导,围绕建设世界一流经济学院的奋斗目标,做实“两个伟大”深度融合,不断提高党的建设质量与科学推进一流事业深度融合。'); + insert into tb_college (collname, collintro) values + ('计算机学院', '计算机学院1958年设立计算机专业,1981年建立计算机科学系,1998年设立计算机学院,2005年5月,为了进一步整合教学和科研资源,学校决定,计算机学院和软件学院行政班子合并统一运作、实行教学和学生管理独立运行的模式。 学院下设三个系:计算机科学与技术系、物联网工程系、计算金融系;两个研究所:图象图形研究所、网络空间安全研究院(2015年成立);三个教学实验中心:计算机基础教学实验中心、IBM技术中心和计算机专业实验中心。'), + ('外国语学院', '四川大学外国语学院设有7个教学单位,6个文理兼收的本科专业;拥有1个一级学科博士授予点,3个二级学科博士授予点,5个一级学科硕士学位授权点,5个二级学科硕士学位授权点,5个硕士专业授权领域,同时还有2个硕士专业学位(MTI)专业;有教职员工210余人,其中教授、副教授80余人,教师中获得中国国内外名校博士学位和正在职攻读博士学位的教师比例占专任教师的60%以上。'), + ('经济管理学院', '四川大学经济学院前身是创办于1905年的四川大学经济科;已故经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代学者刘诗白等曾先后在此任教或学习;1905年,四川大学设经济科;1924年,四川大学经济系成立;1998年,四川大学经济管理学院变更为四川大学经济学院。'); -- 插入学生数据 - insert into tb_student (stuid, stuname, sex, birth, addr, collid) values + insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) values (1001, '杨逍', 1, '1990-3-4', '四川成都', 1), (1002, '任我行', 1, '1992-2-2', '湖南长沙', 1), (1033, '王语嫣', 0, '1989-12-3', '四川成都', 1), @@ -571,10 +573,10 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 delete from tb_student where stuid=4040; -- 更新学生数据 - update tb_student set stuname='杨过', addr='湖南长沙' where stuid=1001; + update tb_student set stuname='杨过', stuaddr='湖南长沙' where stuid=1001; -- 插入老师数据 - insert into tb_teacher (teaid, teaname, title, collid) values + insert into tb_teacher (teaid, teaname, teatitle, collid) values (1122, '张三丰', '教授', 1), (1133, '宋远桥', '副教授', 1), (1144, '杨逍', '副教授', 1), @@ -582,7 +584,7 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 (3366, '韦一笑', '讲师', 3); -- 插入课程数据 - insert into tb_course (couid, couname, credit, teaid) values + insert into tb_course (couid, couname, coucredit, teaid) values (1111, 'Python程序设计', 3, 1122), (2222, 'Web前端开发', 2, 1122), (3333, '操作系统', 4, 1122), @@ -936,15 +938,16 @@ drop index idx_student_name on tb_student; 创建视图。 ```SQL -create view vw_score +create view vw_avg_score as - select sid, round(avg(score), 1) as avgscore from tb_record group by sid; + select sid, round(avg(score), 1) as avgscore + from tb_record group by sid; create view vw_student_score as - select stuname, avgscore - from tb_student, vw_score - where stuid=sid; + select stuname, avgscore + from tb_student, vw_avg_score + where stuid=sid; ``` > **提示**:因为视图不包含数据,所以每次使用视图时,都必须执行查询以获得数据,如果你使用了连接查询、嵌套查询创建了较为复杂的视图,你可能会发现查询性能下降得很厉害。因此,在使用复杂的视图前,应该进行测试以确保其性能能够满足应用的需求。 @@ -1199,7 +1202,7 @@ insert into tb_emp values # 1. 创建数据库连接对象 con = pymysql.connect(host='localhost', port=3306, database='hrs', charset='utf8', - user='root', password='123456') + user='yourname', password='yourpass') try: # 2. 通过连接对象获取游标 with con.cursor() as cursor: @@ -1231,7 +1234,7 @@ insert into tb_emp values no = int(input('编号: ')) con = pymysql.connect(host='localhost', port=3306, database='hrs', charset='utf8', - user='root', password='123456', + user='yourname', password='yourpass', autocommit=True) try: with con.cursor() as cursor: @@ -1263,7 +1266,7 @@ insert into tb_emp values loc = input('所在地: ') con = pymysql.connect(host='localhost', port=3306, database='hrs', charset='utf8', - user='root', password='123456', + user='yourname', password='yourpass', autocommit=True) try: with con.cursor() as cursor: @@ -1291,7 +1294,7 @@ insert into tb_emp values def main(): con = pymysql.connect(host='localhost', port=3306, database='hrs', charset='utf8', - user='root', password='123456') + user='yourname', password='yourpass') try: with con.cursor(cursor=DictCursor) as cursor: cursor.execute('select dno as no, dname as name, dloc as loc from tb_dept') @@ -1334,7 +1337,7 @@ insert into tb_emp values size = int(input('大小: ')) con = pymysql.connect(host='localhost', port=3306, database='hrs', charset='utf8', - user='root', password='123456') + user='yourname', password='yourpass') try: with con.cursor() as cursor: cursor.execute( diff --git a/Day36-40/39-40.NoSQL入门.md b/Day36-40/39-40.NoSQL入门.md index c5fbe4c..0b97878 100644 --- a/Day36-40/39-40.NoSQL入门.md +++ b/Day36-40/39-40.NoSQL入门.md @@ -16,7 +16,7 @@ NoSQL数据库按照其存储类型可以大致分为以下几类: | 图数据库 | Neo4J
FlockDB
JanusGraph | 使用图结构进行语义查询的数据库,它使用节点、边和属性来表示和存储数据。图数据库从设计上,就可以简单快速的检索难以在关系系统中建模的复杂层次结构。 | | 对象数据库 | db4o
Versant | 通过类似面向对象语言的语法操作数据库,通过对象的方式存取数据。 | -> 说明:想了解更多的NoSQL数据库,可以访问。 +> **说明**:想了解更多的NoSQL数据库,可以访问。 ### Redis概述 @@ -107,7 +107,7 @@ redis-server 方式一:通过参数指定认证口令和AOF持久化方式。 ```Shell -redis-server --requirepass 1qaz2wsx --appendonly yes +redis-server --requirepass yourpass --appendonly yes ``` 方式二:通过指定的配置文件来修改Redis的配置。 @@ -119,7 +119,7 @@ redis-server /root/redis-5.0.4/redis.conf 下面我们使用第一种方式来启动Redis并将其置于后台运行,将Redis产生的输出重定向到名为redis.log的文件中。 ```Shell -redis-server --requirepass 1qaz2wsx > redis.log & +redis-server --requirepass yourpass > redis.log & ``` 可以通过ps或者netstat来检查Redis服务器是否启动成功。 @@ -133,7 +133,7 @@ netstat -nap | grep redis-server ```Shell redis-cli -127.0.0.1:6379> auth 1qaz2wsx +127.0.0.1:6379> auth yourpass OK 127.0.0.1:6379> ping PONG @@ -144,7 +144,7 @@ Redis有着非常丰富的数据类型,也有很多的命令来操作这些数 ![](./res/redis-data-types.png) -> 说明:上面的插图来自付磊和张益军先生编著的《Redis开发与运维》一书。 +> **说明**:上面的插图来自付磊和张益军先生编著的《Redis开发与运维》一书。 ```Shell 127.0.0.1:6379> set username admin @@ -274,7 +274,7 @@ python3 ```Python >>> import redis ->>> client = redis.Redis(host='1.2.3.4', port=6379, password='1qaz2wsx') +>>> client = redis.Redis(host='1.2.3.4', port=6379, password='yourpass') >>> client.set('username', 'admin') True >>> client.hset('student', 'name', 'hao') @@ -297,7 +297,7 @@ MongoDB是2009年问世的一个面向文档的数据库管理系统,由C++语 MongoDB将数据存储为一个文档,一个文档由一系列的“键值对”组成,其文档类似于JSON对象,但是MongoDB对JSON进行了二进制处理(能够更快的定位key和value),因此其文档的存储格式称为BSON。关于JSON和BSON的差别大家可以看看MongoDB官方网站的文章[《JSON and BSON》](https://www.mongodb.com/json-and-bson)。 -目前,MongoDB已经提供了对Windows、MacOS、Linux、Solaris等多个平台的支持,而且也提供了多种开发语言的驱动程序,Python当然是其中之一。 +目前,MongoDB已经提供了对Windows、macOS、Linux、Solaris等多个平台的支持,而且也提供了多种开发语言的驱动程序,Python当然是其中之一。 #### MongoDB的安装和配置 @@ -320,7 +320,7 @@ mongod --bind_ip 172.18.61.250 2018-06-03T18:03:28.945+0800 I NETWORK [initandlisten] waiting for connections on port 27017 ``` -> 说明:上面的操作中,export命令是设置PATH环境变量,这样可以在任意路径下执行mongod来启动MongoDB服务器。MongoDB默认保存数据的路径是/data/db目录,为此要提前创建该目录。此外,在使用mongod启动MongoDB服务器时,--bind_ip参数用来将服务绑定到指定的IP地址,也可以用--port参数来指定端口,默认端口为27017。 +> **说明**:上面的操作中,export命令是设置PATH环境变量,这样可以在任意路径下执行mongod来启动MongoDB服务器。MongoDB默认保存数据的路径是/data/db目录,为此要提前创建该目录。此外,在使用mongod启动MongoDB服务器时,--bind_ip参数用来将服务绑定到指定的IP地址,也可以用--port参数来指定端口,默认端口为27017。 #### MongoDB基本概念 diff --git a/Day36-40/code/HRS_create_and_init.sql b/Day36-40/code/HRS_create_and_init.sql index b8bc864..4b991e4 100644 --- a/Day36-40/code/HRS_create_and_init.sql +++ b/Day36-40/code/HRS_create_and_init.sql @@ -1,5 +1,5 @@ drop database if exists hrs; -create database hrs default charset utf8; +create database hrs default charset utf8mb4; use hrs; @@ -14,6 +14,8 @@ dloc varchar(20) not null comment '所在地', primary key (dno) ); +-- alter table tb_dept add constraint pk_dept_dno primary key(dno); + insert into tb_dept values (10, '会计部', '北京'), (20, '研发部', '成都'), @@ -29,10 +31,13 @@ mgr int comment '主管编号', sal int not null comment '员工月薪', comm int comment '每月补贴', dno int comment '所在部门编号', -primary key (eno) +primary key (eno), +foreign key (dno) references tb_dept(dno), +foreign key (mgr) references tb_emp(eno) ); -alter table tb_emp add constraint fk_emp_dno foreign key (dno) references tb_dept (dno); +-- alter table tb_emp add constraint fk_emp_mgr foreign key (mgr) references tb_emp (eno); +-- alter table tb_emp add constraint fk_emp_dno foreign key (dno) references tb_dept (dno); insert into tb_emp values (7800, '张三丰', '总裁', null, 9000, 1200, 20), @@ -51,7 +56,7 @@ insert into tb_emp values (3588, '朱九真', '会计', 5566, 2500, null, 10); --- 查询月薪最高的员工姓名和工资 +-- 查询月薪最高的员工姓名和月薪 -- 查询员工的姓名和年薪((月薪+补贴)*13) @@ -59,14 +64,14 @@ insert into tb_emp values -- 查询所有部门的名称和人数 --- 查询月薪最高的员工(Boss除外)的姓名和工资 +-- 查询月薪最高的员工(Boss除外)的姓名和月薪 --- 查询薪水超过平均薪水的员工的姓名和工资 +-- 查询薪水超过平均薪水的员工的姓名和月薪 --- 查询薪水超过其所在部门平均薪水的员工的姓名、部门编号和工资 +-- 查询薪水超过其所在部门平均薪水的员工的姓名、部门编号和月薪 --- 查询部门中薪水最高的人姓名、工资和所在部门名称 +-- 查询部门中薪水最高的人姓名、月薪和所在部门名称 -- 查询主管的姓名和职位 --- 查询月薪排名4~6名的员工姓名和工资 +-- 查询月薪排名4~6名的员工排名、姓名和月薪 diff --git a/Day36-40/code/SRS_create_and_init.sql b/Day36-40/code/SRS_create_and_init.sql index 301c7bc..637e514 100644 --- a/Day36-40/code/SRS_create_and_init.sql +++ b/Day36-40/code/SRS_create_and_init.sql @@ -2,7 +2,7 @@ drop database if exists school; -- 创建名为school的数据库并设置默认的字符集和排序方式 -create database school default charset utf8 collate utf8_bin; +create database school default charset utf8; -- 切换到school数据库上下文环境 use school; @@ -10,35 +10,32 @@ use school; -- 创建学院表 create table tb_college ( -collid int not null auto_increment comment '编号', -collname varchar(50) not null comment '名称', -collmaster varchar(20) not null comment '院长', -collweb varchar(511) default '' comment '网站', +collid int auto_increment comment '编号', +collname varchar(50) not null comment '名称', +collintro varchar(500) default '' comment '介绍', primary key (collid) ); -- 创建学生表 create table tb_student ( -stuid int not null comment '学号', -stuname varchar(20) not null comment '姓名', -stusex bit default 1 comment '性别', -stubirth date not null comment '出生日期', -stuaddr varchar(255) default '' comment '籍贯', -collid int not null comment '所属学院', +stuid int not null comment '学号', +stuname varchar(20) not null comment '姓名', +stusex boolean default 1 comment '性别', +stubirth date not null comment '出生日期', +stuaddr varchar(255) default '' comment '籍贯', +collid int not null comment '所属学院', primary key (stuid), foreign key (collid) references tb_college (collid) ); --- alter table tb_student add constraint fk_student_collid foreign key (collid) references tb_college (collid); - -- 创建教师表 create table tb_teacher ( -teaid int not null comment '工号', -teaname varchar(20) not null comment '姓名', -teatitle varchar(10) default '助教' comment '职称', -collid int not null comment '所属学院', +teaid int not null comment '工号', +teaname varchar(20) not null comment '姓名', +teatitle varchar(10) default '助教' comment '职称', +collid int not null comment '所属学院', primary key (teaid), foreign key (collid) references tb_college (collid) ); @@ -46,48 +43,54 @@ foreign key (collid) references tb_college (collid) -- 创建课程表 create table tb_course ( -couid int not null comment '编号', -couname varchar(50) not null comment '名称', -coucredit int not null comment '学分', -teaid int not null comment '授课老师', +couid int not null comment '编号', +couname varchar(50) not null comment '名称', +coucredit int not null comment '学分', +teaid int not null comment '授课老师', primary key (couid), foreign key (teaid) references tb_teacher (teaid) ); -- 创建选课记录表 -create table tb_score +create table tb_record ( -scid int auto_increment comment '选课记录编号', -stuid int not null comment '选课学生', -couid int not null comment '所选课程', -scdate datetime comment '选课时间日期', -scmark decimal(4,1) comment '考试成绩', -primary key (scid), -foreign key (stuid) references tb_student (stuid), -foreign key (couid) references tb_course (couid) +recid int auto_increment comment '选课记录编号', +sid int not null comment '选课学生', +cid int not null comment '所选课程', +seldate datetime default now() comment '选课时间日期', +score decimal(4,1) comment '考试成绩', +primary key (recid), +foreign key (sid) references tb_student (stuid), +foreign key (cid) references tb_course (couid), +unique (sid, cid) ); --- 添加唯一性约束(一个学生选某个课程只能选一次) -alter table tb_score add constraint uni_score_stuid_couid unique (stuid, couid); - -- 插入学院数据 -insert into tb_college (collname, collmaster, collweb) values -('计算机学院', '左冷禅', 'http://www.abc.com'), -('外国语学院', '岳不群', 'http://www.xyz.com'), -('经济管理学院', '风清扬', 'http://www.foo.com'); +insert into tb_college (collname, collintro) values +('计算机学院', '计算机学院1958年设立计算机专业,1981年建立计算机科学系,1998年设立计算机学院,2005年5月,为了进一步整合教学和科研资源,学校决定,计算机学院和软件学院行政班子合并统一运作、实行教学和学生管理独立运行的模式。 学院下设三个系:计算机科学与技术系、物联网工程系、计算金融系;两个研究所:图象图形研究所、网络空间安全研究院(2015年成立);三个教学实验中心:计算机基础教学实验中心、IBM技术中心和计算机专业实验中心。'), +('外国语学院', '四川大学外国语学院设有7个教学单位,6个文理兼收的本科专业;拥有1个一级学科博士授予点,3个二级学科博士授予点,5个一级学科硕士学位授权点,5个二级学科硕士学位授权点,5个硕士专业授权领域,同时还有2个硕士专业学位(MTI)专业;有教职员工210余人,其中教授、副教授80余人,教师中获得中国国内外名校博士学位和正在职攻读博士学位的教师比例占专任教师的60%以上。'), +('经济管理学院', '四川大学经济学院前身是创办于1905年的四川大学经济科;已故经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代学者刘诗白等曾先后在此任教或学习;1905年,四川大学设经济科;1924年,四川大学经济系成立;1998年,四川大学经济管理学院变更为四川大学经济学院。'); -- 插入学生数据 -insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) values -(1001, '杨逍', 1, '1990-3-4', '四川成都', 1), -(1002, '任我行', 1, '1992-2-2', '湖南长沙', 1), -(1033, '王语嫣', 0, '1989-12-3', '四川成都', 1), -(1572, '岳不群', 1, '1993-7-19', '陕西咸阳', 1), -(1378, '纪嫣然', 0, '1995-8-12', '四川绵阳', 1), -(1954, '林平之', 1, '1994-9-20', '福建莆田', 1), -(2035, '东方不败', 1, '1988-6-30', null, 2), -(3011, '林震南', 1, '1985-12-12', '福建莆田', 3), -(3755, '项少龙', 1, '1993-1-25', null, 3), -(3923, '杨不悔', 0, '1985-4-17', '四川成都', 3); +insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) +values + (1001, '杨逍', 1, '1990-3-4', '四川成都', 1), + (1002, '任我行', 1, '1992-2-2', '湖南长沙', 1), + (1033, '王语嫣', 0, '1989-12-3', '四川成都', 1), + (1572, '岳不群', 1, '1993-7-19', '陕西咸阳', 1), + (1378, '纪嫣然', 0, '1995-8-12', '四川绵阳', 1), + (1954, '林平之', 1, '1994-9-20', '福建莆田', 1), + (2035, '东方不败', 1, '1988-6-30', null, 2), + (3011, '林震南', 1, '1985-12-12', '福建莆田', 3), + (3755, '项少龙', 1, '1993-1-25', null, 3), + (3923, '杨不悔', 0, '1985-4-17', '四川成都', 3), + (4040, '炼腰的隔壁老王', 1, '1989-1-1', '四川成都', 2); + +-- 删除学生数据 +delete from tb_student where stuid=4040; + +-- 更新学生数据 +update tb_student set stuname='杨过', stuaddr='湖南长沙' where stuid=1001; -- 插入老师数据 insert into tb_teacher (teaid, teaname, teatitle, collid) values @@ -110,7 +113,7 @@ insert into tb_course (couid, couname, coucredit, teaid) values (9999, '审计学', 3, 3366); -- 插入选课数据 -insert into tb_score (stuid, couid, scdate, scmark) values +insert into tb_record (sid, cid, seldate, score) values (1001, 1111, '2017-09-01', 95), (1001, 2222, '2017-09-01', 87.5), (1001, 3333, '2017-09-01', 100), @@ -125,9 +128,9 @@ insert into tb_score (stuid, couid, scdate, scmark) values (1378, 1111, '2017-09-05', 82), (1378, 7777, '2017-09-02', 65.5), (2035, 7777, '2018-09-03', 88), -(2035, 9999, curdate(), null), -(3755, 1111, date(now()), null), -(3755, 8888, date(now()), null), +(2035, 9999, default, null), +(3755, 1111, default, null), +(3755, 8888, default, null), (3755, 9999, '2017-09-01', 92); -- 查询所有学生信息 @@ -227,8 +230,6 @@ select stuname, couname, scmark from tb_student t1 inner join tb_score t3 on t1. select stuname, couname, scmark from tb_student t1 inner join tb_score t3 on t1.stuid=t3.stuid inner join tb_course t2 on t2.couid=t3.couid where scmark is not null order by scmark desc limit 10, 5; --- 单表:65535TB --- 单列:4G - LONGBLOB (Binary Large OBject) / LONGTEXT -- 查询选课学生的姓名和平均成绩(子查询和连接查询) select stuname, avgmark from tb_student t1, (select stuid, avg(scmark) as avgmark from tb_score group by stuid) t2 where t1.stuid=t2.stuid; diff --git a/Day36-40/code/contact/main.py b/Day36-40/code/contact/main.py index 2e95a33..70ebb36 100644 --- a/Day36-40/code/contact/main.py +++ b/Day36-40/code/contact/main.py @@ -171,8 +171,8 @@ def find_contacters(con): def main(): - con = pymysql.connect(host='120.77.222.217', port=3306, - user='root', passwd='123456', + con = pymysql.connect(host='1.2.3.4', port=3306, + user='yourname', passwd='yourpass', db='address', charset='utf8', autocommit=True, cursorclass=pymysql.cursors.DictCursor) diff --git a/Day36-40/res/conceptual_model.png b/Day36-40/res/conceptual_model.png index 2b93a21..0e87815 100644 Binary files a/Day36-40/res/conceptual_model.png and b/Day36-40/res/conceptual_model.png differ diff --git a/Day36-40/res/er_diagram.png b/Day36-40/res/er_diagram.png index e851a30..434216e 100644 Binary files a/Day36-40/res/er_diagram.png and b/Day36-40/res/er_diagram.png differ diff --git a/Day36-40/res/redis-aof.png b/Day36-40/res/redis-aof.png index bdd13c6..f7575df 100644 Binary files a/Day36-40/res/redis-aof.png and b/Day36-40/res/redis-aof.png differ diff --git a/Day36-40/res/redis-bind-and-port.png b/Day36-40/res/redis-bind-and-port.png index 1abc58f..dc26d98 100644 Binary files a/Day36-40/res/redis-bind-and-port.png and b/Day36-40/res/redis-bind-and-port.png differ diff --git a/Day36-40/res/redis-data-types.png b/Day36-40/res/redis-data-types.png index bb6d74e..a45625c 100644 Binary files a/Day36-40/res/redis-data-types.png and b/Day36-40/res/redis-data-types.png differ diff --git a/Day36-40/res/redis-databases.png b/Day36-40/res/redis-databases.png index d076640..b6f8a92 100644 Binary files a/Day36-40/res/redis-databases.png and b/Day36-40/res/redis-databases.png differ diff --git a/Day36-40/res/redis-hash.png b/Day36-40/res/redis-hash.png index 29329af..0d86fd0 100644 Binary files a/Day36-40/res/redis-hash.png and b/Day36-40/res/redis-hash.png differ diff --git a/Day36-40/res/redis-list.png b/Day36-40/res/redis-list.png index 2ccd893..00f23f3 100644 Binary files a/Day36-40/res/redis-list.png and b/Day36-40/res/redis-list.png differ diff --git a/Day36-40/res/redis-rdb-1.png b/Day36-40/res/redis-rdb-1.png index 55dcc61..b868bc5 100644 Binary files a/Day36-40/res/redis-rdb-1.png and b/Day36-40/res/redis-rdb-1.png differ diff --git a/Day36-40/res/redis-rdb-3.png b/Day36-40/res/redis-rdb-3.png index fd9983e..958702f 100644 Binary files a/Day36-40/res/redis-rdb-3.png and b/Day36-40/res/redis-rdb-3.png differ diff --git a/Day36-40/res/redis-replication.png b/Day36-40/res/redis-replication.png index c1f67a0..657508b 100644 Binary files a/Day36-40/res/redis-replication.png and b/Day36-40/res/redis-replication.png differ diff --git a/Day36-40/res/redis-security.png b/Day36-40/res/redis-security.png index 44c2fee..3c70471 100644 Binary files a/Day36-40/res/redis-security.png and b/Day36-40/res/redis-security.png differ diff --git a/Day36-40/res/redis-set.png b/Day36-40/res/redis-set.png index 1962b16..b9f15c3 100644 Binary files a/Day36-40/res/redis-set.png and b/Day36-40/res/redis-set.png differ diff --git a/Day36-40/res/redis-slow-logs.png b/Day36-40/res/redis-slow-logs.png index 474a1db..10816aa 100644 Binary files a/Day36-40/res/redis-slow-logs.png and b/Day36-40/res/redis-slow-logs.png differ diff --git a/Day36-40/res/redis-string.png b/Day36-40/res/redis-string.png index 7cef9df..60d9b5b 100644 Binary files a/Day36-40/res/redis-string.png and b/Day36-40/res/redis-string.png differ diff --git a/Day36-40/res/redis-zset.png b/Day36-40/res/redis-zset.png index d3df613..c87b486 100644 Binary files a/Day36-40/res/redis-zset.png and b/Day36-40/res/redis-zset.png differ diff --git a/Day41-55/41.Django快速上手.md b/Day41-55/41.Django快速上手.md new file mode 100644 index 0000000..ff50eb7 --- /dev/null +++ b/Day41-55/41.Django快速上手.md @@ -0,0 +1,339 @@ +## Django快速上手 + +Web开发的早期阶段,开发者需要手动编写每个页面,例如一个新闻门户网站,每天都要修改它的HTML页面,随着网站规模和体量的增大,这种做法一定是非常糟糕的。为了解决这个问题,开发人员想到了用程序来为Web服务器生成动态内容,也就是说网页中的动态内容不再通过手动编写而是通过程序自动生成。最早的时候,这项技术被称为CGI(公共网关接口),当然随着时间的推移,CGI暴露出的问题也越来越多,例如大量重复的样板代码,总体性能较为低下等。在时代呼唤新英雄的背景下,PHP、ASP、JSP这类Web应用开发技术在上世纪90年代中后期如雨后春笋般涌现。通常我们说的Web应用是指通过浏览器来访问网络资源的应用程序,因为浏览器的普及性以及易用性,Web应用使用起来方便简单,免除了安装和更新应用程序带来的麻烦;站在开发者的角度,也不用关心用户使用什么样的操作系统,甚至不用区分是PC端还是移动端。 + +### Web应用机制和术语 + +下图向我们展示了Web应用的工作流程,其中涉及到的术语如下表所示。 + +![](./res/web-application.png) + +> 说明:相信有经验的读者会发现,这张图中其实还少了很多东西,例如反向代理服务器、数据库服务器、防火墙等,而且图中的每个节点在实际项目部署时可能是一组节点组成的集群。当然,如果你对这些没有什么概念也不要紧,继续下去就行了,后面会给大家一一讲解的。 + +| 术语 | 解释 | +| ------------- | ------------------------------------------------------------ | +| **URL/URI** | 统一资源定位符/统一资源标识符,网络资源的唯一标识 | +| **域名** | 与Web服务器地址对应的一个易于记忆的字符串名字 | +| **DNS** | 域名解析服务,可以将域名转换成对应的IP地址 | +| **IP地址** | 网络上的主机的身份标识,通过IP地址可以区分不同的主机 | +| **HTTP** | 超文本传输协议,构建在TCP之上的应用级协议,万维网数据通信的基础 | +| **反向代理** | 代理客户端向服务器发出请求,然后将服务器返回的资源返回给客户端 | +| **Web服务器** | 接受HTTP请求,然后返回HTML文件、纯文本文件、图像等资源给请求者 | +| **Nginx** | 高性能的Web服务器,也可以用作[反向代理](https://zh.wikipedia.org/wiki/%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86),[负载均衡](https://zh.wikipedia.org/wiki/%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1) 和 [HTTP缓存](https://zh.wikipedia.org/wiki/HTTP%E7%BC%93%E5%AD%98) | + +#### HTTP协议 + +这里我们先费一些笔墨来说说HTTP这个协议。HTTP(超文本传输协议)是构建于TCP(传输控制协议)之上应用级协议,它利用了TCP提供的可靠的传输服务实现了Web应用中的数据交换。按照维基百科上的介绍,设计HTTP最初的目的是为了提供一种发布和接收[HTML](https://zh.wikipedia.org/wiki/HTML)页面的方法,也就是说这个协议是浏览器和Web服务器之间传输的数据的载体。关于这个协议的详细信息以及目前的发展状况,大家可以阅读[《HTTP 协议入门》](http://www.ruanyifeng.com/blog/2016/08/http.html)、[《互联网协议入门》](http://www.ruanyifeng.com/blog/2012/05/internet_protocol_suite_part_i.html)系列以及[《图解HTTPS协议》](http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html)这几篇文章进行了解。下图是我在四川省网络通信技术重点实验室学习和工作期间使用开源协议分析工具Ethereal(抓包工具WireShark的前身)截取的访问百度首页时的HTTP请求和响应的报文(协议数据),由于Ethereal截取的是经过网络适配器的数据,因此可以清晰的看到从物理链路层到应用层的协议数据。 + +HTTP请求(请求行+请求头+空行+[消息体]): + +![](./res/http-request.png) + +HTTP响应(响应行+响应头+空行+消息体): + +![](./res/http-response.png) + +> **说明**:这两张图是在2009年9月10日凌晨获得的,但愿这两张如同泛黄的照片般的截图能帮助你了解HTTP到底是什么样子的。当然,如果没有专业的抓包工具,也可以通过浏览器提供的“开发者工具”来查看HTTP请求和响应的数据格式。 + +### Django概述 + +Python的Web框架有上百个,比它的关键字还要多。所谓Web框架,就是用于开发Web服务器端应用的基础设施,说得通俗一点就是一系列封装好的模块和工具。事实上,即便没有Web框架,我们仍然可以通过socket或[CGI](https://zh.wikipedia.org/wiki/%E9%80%9A%E7%94%A8%E7%BD%91%E5%85%B3%E6%8E%A5%E5%8F%A3)来开发Web服务器端应用,但是这样做的成本和代价在商业项目中通常是不能接受的。通过Web框架,我们可以化繁为简,降低创建、更新、扩展应用程序的工作量。刚才我们说到Python有上百个Web框架,这些框架包括Django、Flask、Tornado、Sanic、Pyramid、Bottle、Web2py、web.py等。 + +在上述Python的Web框架中,Django无疑是最有代表性的重量级选手,开发者可以基于Django快速的开发可靠的Web应用程序,因为它减少了Web开发中不必要的开销,对常用的设计和开发模式进行了封装,并对MVC架构提供了支持(Django中称之为MTV架构)。MVC是软件系统开发领域中一种放之四海而皆准的架构,它将系统中的组件分为模型(Model)、视图(View)和控制器(Controller)三个部分并借此实现模型(数据)和视图(显示)的解耦合。由于模型和视图进行了分离,所以需要一个中间人将解耦合的模型和视图联系起来,扮演这个角色的就是控制器。稍具规模的软件系统都会使用MVC架构(或者是从MVC演进出的其他架构),Django项目中我们称之为MTV,MTV中的M跟MVC中的M没有区别,就是代表数据的模型,T代表了网页模板(显示数据的视图),而V代表了视图函数,在Django框架中,视图函数和Django框架本身一起扮演了MVC中C的角色。 + +![](./res/mvc.png) + +Django框架诞生于2003年,它是一个在真正的应用中成长起来的项目,由劳伦斯出版集团旗下在线新闻网站的内容管理系统(CMS)研发团队(主要是Adrian Holovaty和Simon Willison)开发,以比利时的吉普赛爵士吉他手Django Reinhardt来命名。Django框架在2005年夏天作为开源框架发布,使用Django框架能用很短的时间构建出功能完备的网站,因为它代替程序员完成了那些重复乏味的劳动,剩下真正有意义的核心业务给程序员来开发,这一点就是对DRY(Don't Repeat Yourself)理念的最好践行。许多成功的网站和应用都是基于Python语言进行开发的,国内比较有代表性的网站包括:知乎、豆瓣网、果壳网、搜狐闪电邮箱、101围棋网、海报时尚网、背书吧、堆糖、手机搜狐网、咕咚、爱福窝、果库等,其中不乏使用了Django框架的产品。 + +### 快速上手 + +#### 第一个Django项目 + +1. 检查Python环境:Django 1.11需要Python 2.7或Python 3.4以上的版本;Django 2.0需要Python 3.4以上的版本;Django 2.1和2.2需要Python 3.5以上的版本;Django 3.0需要Python 3.6以上版本。 + + > **说明**:Django框架不同版本所需的Python解释器环境,可以在Django官方文档的[FAQ](https://docs.djangoproject.com/zh-hans/3.0/faq/install/#faq-python-version-support)中找到。 + + 可以在macOS的终端中输入下面的命令检查Python解释器版本,Windows系统可以在命令行提示符中输入`python --version`。 + + ```Bash +python3 --version + ``` + + 也可以在Python的交互式环境中执行下面的代码来查看Python解释器的版本。 + + ```Shell + import sys + sys.version + sys.version_info + ``` + +2. 更新包管理工具并安装Django环境(用于创建Django项目)。 + + > **说明**:在更新这个文档时,Django最新的正式版本是3.0.7,Django 3.0提供了对ASGI的支持,可以实现全双工的异步通信,但是目前的使用体验一般,所以暂时不推荐大家使用Django 3.0,下面我们安装的是Django 2.2.13版本。使用`pip`安装三方库和工具时,可以通过`==`来指定安装的版本。 + + ```Bash + pip3 install -U pip + pip3 install django==2.2.13 + ``` + +3. 检查Django环境并使用`django-admin`命令创建Django项目(项目名称为hellodjango)。 + + ```Shell + django-admin --version + django-admin startproject hellodjango + ``` + +4. 用PyCharm打开创建好的Djang项目,并为其添加虚拟环境。 + + ![](res/pycharm-django-project.png) + + 如上图所示,PyCharm的项目浏览器中,最顶层的文件夹`hellodjango`是Python项目文件夹,这个文件夹的名字并不重要,Django项目也不关心这个文件夹叫什么名字。该文件夹下有一个同名的文件夹,它是Django项目文件夹,其中包含了`__init__.py`、`settings.py`、`urls.py`、`wsgi.py`四个文件,与名为`hellodjango`的Django项目文件夹同级的还有一个名为`manage.py` 的文件,这些文件的作用如下所示: + + - `hellodjango/__init__.py`:空文件,告诉Python解释器这个目录应该被视为一个Python的包。 + - `hellodjango/settings.py`:Django项目的配置文件。 + - `hellodjango/urls.py`:Django项目的URL映射声明,就像是网站的“目录”。 + - `hellodjango/wsgi.py`:项目运行在WSGI兼容Web服务器上的入口文件。 + - `manage.py`: 管理Django项目的脚本程序。 + + > 说明:WSGI全称是Web服务器网关接口,维基百科上给出的解释是“为Python语言定义的[Web服务器](https://zh.wikipedia.org/wiki/%E7%B6%B2%E9%A0%81%E4%BC%BA%E6%9C%8D%E5%99%A8)和[Web应用程序](https://zh.wikipedia.org/wiki/%E7%BD%91%E7%BB%9C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F)或框架之间的一种简单而通用的接口”。 + + 创建虚拟环境的界面如下图所示。 + + ![pycharm-django-virtual-environment](res/pycharm-django-virtual-environment.png) + +5. 安装项目依赖项。 + + 方法一:打开PyCharm的终端,在终端中通过`pip`命令安装Django项目的依赖项。 + + > **说明**:由于已经基于Python 3解释器环境为项目创建了虚拟环境,所以虚拟环境中的`python`命令对应的是Python 3的解释器,而`pip`命令对应的是Python 3的包管理工具。 + + ```Shell + pip install django==2.2.13 + ``` + + 方法二:在PyCharm的偏好设置中,可以找到项目的解释器环境和已经安装的三方库,可以通过点击添加按钮来安装新的依赖项,需要提醒大家的是在安装Django依赖项时,需要指定版本号,否则将默认安装更新本文时最新的3.0.7版本。 + + ![](res/pycharm-install-django.png) + + 下图展示了Django版本和Python版本的对应关系,请大家自行对号入座。 + + | Django版本 | Python版本 | + | ---------- | ----------------------------------------- | + | 1.8 | 2.7、3.2、3.3、3.4、3.5 | + | 1.9、1.10 | 2.7、3.4、3.5 | + | 1.11 | 2.7、3.4、3.5、3.6、3.7(Django 1.11.17) | + | 2.0 | 3.4、3.5、3.6、3.7 | + | 2.1 | 3.5、3.6、3.7 | + | 2.2 | 3.5、3.6、3.7、3.8(Django 2.2.8) | + | 3.0 | 3.6、3.7、3.8 | + +6. 启动Django自带的服务器运行项目。 + + 方法一:在“Run”菜单选择“Edit Configuration”,配置“Django server”运行项目(适用于专业版PyCharm)。 + + ![](res/pycharm-django-server.png) + + 方法二:在“Run”菜单选择“Edit Configuration”,配置运行“Python”程序运行项目(适用于专业版和社区版PyCharm)。 + + ![](res/pycharm-python-manage.png) + + 方法三:在PyCharm的终端(Terminal)中通过命令运行项目(适用于专业版和社区版PyCharm)。 + + ```Shell + python manage.py runserver + ``` + +7. 查看运行效果。 + + 在浏览器中输入`http://127.0.0.1:8000`访问我们的服务器,效果如下图所示。 + + ![](./res/django-index-1.png) + + > **说明**: + > + > 1. 刚刚启动的Django自带的服务器只能用于开发和测试环境,因为这个服务器是纯Python编写的轻量级Web服务器,不适合在生产环境中使用。 + > 2. 如果修改了代码,不需要为了让修改的代码生效而重新启动Django自带的服务器。但是,在添加新的项目文件时,该服务器不会自动重新加载,这个时候就得手动重启服务器。 + > 3. 可以在终端中通过`python manage.py help`命令查看Django管理脚本程序可用的命令参数。 + > 4. 使用`python manage.py runserver`启动服务器时,可以在后面添加参数来指定IP地址和端口号,默认情况下启动的服务器将运行在本机的`8000`端口。 + > 5. 在终端中运行的服务器,可以通过Ctrl+C来停止它 。通过PyCharm的“运行配置”运行的服务器直接点击窗口上的关闭按钮就可以终止服务器的运行。 + > 6. 不能在同一个端口上启动多个服务器,因为会导致地址的冲突(端口是对IP地址的扩展,也是计算机网络地址的一部分)。 +8. 修改项目的配置文件`settings.py`。 + + Django是一个支持国际化和本地化的框架,因此刚才我们看到的Django项目的默认首页也是支持国际化的,我们可以通过修改配置文件将默认语言修改为中文,时区设置为东八区。 + + 找到修改前的配置(在`settings.py`文件第100行以后)。 + + ```Python + LANGUAGE_CODE = 'en-us' + TIME_ZONE = 'UTC' + ``` + + 修改为以下内容。 + + ```Python + LANGUAGE_CODE = 'zh-hans' + TIME_ZONE = 'Asia/Chongqing' + ``` + + 刷新刚才的页面,可以看到修改语言代码和时区之后的结果。 + + ![](./res/django-index-2.png) + +#### 创建自己的应用 + +如果要开发自己的Web应用,需要先在Django项目中创建“应用”,一个Django项目可以包含一个或多个应用。 + +1. 在PyCharm的终端中执行下面的命令,创建名为`first`的应用。 + + ```Shell + python manage.py startapp first + ``` + + 执行上面的命令会在当前路径下创建`first`目录,其目录结构如下所示: + + - `__init__.py`:一个空文件,告诉Python解释器这个目录应该被视为一个Python的包。 + - `admin.py`:可以用来注册模型,用于在Django框架自带的管理后台中管理模型。 + - `apps.py`:当前应用的配置文件。 + - `migrations`:存放与模型有关的数据库迁移信息。 + - `__init__.py`:一个空文件,告诉Python解释器这个目录应该被视为一个Python的包。 + - `models.py`:存放应用的数据模型(MTV中的M)。 + - `tests.py`:包含测试应用各项功能的测试类和测试函数。 + - `views.py`:处理用户HTTP请求并返回HTTP响应的函数或类(MTV中的V)。 + +2. 修改应用目录下的视图文件`views.py`。 + + ```Python + from django.http import HttpResponse + + + def show_index(request): + return HttpResponse('

Hello, Django!

') + ``` + +4. 修改Django项目目录下的`urls.py`文件,将视图函数和用户在浏览器中请求的路径对应。 + + ```Python + from django.contrib import admin + from django.urls import path, include + + from first.views import show_index + + urlpatterns = [ + path('admin/', admin.site.urls), + path('hello/', show_index), + ] + ``` + +5. 重新运行项目,并打开浏览器中访问`http://127.0.0.1:8000/hello/`。 + +5. 上面我们通过代码为浏览器生成了内容,但仍然是静态内容,如果要生成动态内容,可以修改`views.py`文件并添加如下所示的代码。 + + ```Python + from random import sample + + from django.http import HttpResponse + + + def show_index(request): + fruits = [ + 'Apple', 'Orange', 'Pitaya', 'Durian', 'Waxberry', 'Blueberry', + 'Grape', 'Peach', 'Pear', 'Banana', 'Watermelon', 'Mango' + ] + selected_fruits = sample(fruits, 3) + content = '

今天推荐的水果是:

' + content += '
' + content += '
    ' + for fruit in selected_fruits: + content += f'
  • {fruit}
  • ' + content += '
' + return HttpResponse(content) + ``` + +6. 刷新页面查看程序的运行结果,看看每次刷新的网页的时候,是不是可以看到不一样的内容。 + + +#### 使用模板 + +上面通过拼接HTML代码的方式为浏览器生成动态内容的做法在实际开发中是无能接受的,因为实际项目中的前端页面可能非常复杂,无法用这种拼接动态内容的方式来完成,这一点大家一定能够想到。为了解决这个问题,我们可以提前准备一个模板页(MTV中的T),所谓模板页就是一个带占位符和模板指令的HTML页面。 + +Django框架中有一个名为`render`的便捷函数可以来完成渲染模板的操作。所谓的渲染就是用数据替换掉模板页中的模板指令和占位符,当然这里的渲染称为后端渲染,即在服务器端完成页面的渲染再输出到浏览器中。后端渲染的做法在Web应用的访问量较大时,会让服务器承受较大的负担,所以越来越多的Web应用会选择前端渲染的方式,即服务器只提供页面所需的数据(通常是JSON格式),在浏览器中通过JavaScript代码获取这些数据并渲染页面上。关于前端渲染的内容,我们会在后续的课程中为大家讲解,目前我们使用的是通过模板页进行后端渲染的做法,具体步骤如下所示。 + +使用模板页的步骤如下所示。 + +1. 在项目目录下创建名为templates文件夹。 + + ![](res/pycharm-django-template.png) + +2. 添加模板页`index.html`。 + + > **说明**:实际项目开发中,静态页由前端开发者提供,后端开发者需要将静态页修改为模板页,以便通过Python程序对其进行渲染,这种做法就是上面提到的后端渲染。 + + ```HTML + + + + + 首页 + + + +

今天推荐的水果是:

+
+
    + {% for fruit in fruits %} +
  • {{ fruit }}
  • + {% endfor %} +
+ + + ``` + 在上面的模板页中我们使用了`{{ fruit }}`这样的模板占位符语法,也使用了`{% for %}`这样的模板指令,这些都是Django模板语言(DTL)的一部分。关于模板语法和指令,大家可以看看官方文档,相信这些内容还是很容易理解的,并不需要过多的赘述,大家也可以参考[官方文档]()了解模板指令和语法。 + +3. 修改`views.py`文件,调用`render`函数渲染模板页。 + + ```Python + from random import sample + + from django.shortcuts import render + + + def show_index(request): + fruits = [ + 'Apple', 'Orange', 'Pitaya', 'Durian', 'Waxberry', 'Blueberry', + 'Grape', 'Peach', 'Pear', 'Banana', 'Watermelon', 'Mango' + ] + selected_fruits = sample(fruits, 3) + return render(request, 'index.html', {'fruits': selected_fruits}) + ``` + + `render`函数的第一个参数是请求对象request,第二个参数是我们要渲染的模板页的名字,第三个参数是要渲染到页面上的数据,我们通过一个字典将数据交给模板页,字典中的键就是模板页中使用的模板指令或占位符中的变量名。 + +4. 到此为止,视图函数中的`render`还无法找到模板文件`index.html`,需要修改`settings.py`文件,配置模板文件所在的路径。修改`settings.py`文件,找到`TEMPLATES`配置,修改其中的`DIRS`配置。 + + ```Python + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates'), ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, + ] + ``` + +5. 重新运行项目或直接刷新页面查看结果。 + +### 总结 + +至此,我们已经利用Django框架完成了一个非常小的Web应用,虽然它并没有任何的实际价值,但是可以通过这个项目对Django框架有一个感性的认识。学习Django最好的资料肯定是它的[官方文档](https://docs.djangoproject.com/zh-hans/2.0/),官方文档提供了对多国语言的支持,而且有新手教程引导初学者学习使用Django框架,建议大家通过阅读Django的官方文档来学习和使用这个框架。当然图灵社区出版的[《Django基础教程》](http://www.ituring.com.cn/book/2630)也是非常适合初学者的入门级读物,有兴趣的读者可以点击链接进行购买。 diff --git a/Day41-55/41.快速上手.md b/Day41-55/41.快速上手.md deleted file mode 100644 index 76a9af0..0000000 --- a/Day41-55/41.快速上手.md +++ /dev/null @@ -1,430 +0,0 @@ -## 快速上手 - -Web开发的早期阶段,开发者需要手动编写每个页面,例如一个新闻门户网站,每天都要修改它的HTML页面,随着网站规模和体量的增大,这种方式就变得极度糟糕。为了解决这个问题,开发人员想到了用外部程序来为Web服务器生成动态内容,也就是说HTML页面以及页面中的动态内容不再通过手动编写而是通过程序自动生成。最早的时候,这项技术被称为CGI(公共网关接口),当然随着时间的推移,CGI暴露出的问题也越来越多,例如大量重复的样板代码,总体性能较为低下等,因此在时代呼唤新英雄的背景下,PHP、ASP、JSP这类Web应用开发技术在上世纪90年代中后期如雨后春笋般涌现。通常我们说的Web应用是指通过浏览器来访问网络资源的应用程序,因为浏览器的普及性以及易用性,Web应用使用起来方便简单,免除了安装和更新应用程序带来的麻烦,而且也不用关心用户到底用的是什么操作系统,甚至不用区分是PC端还是移动端。 - -### Web应用机制和术语 - -下图向我们展示了Web应用的工作流程,其中涉及到的术语如下表所示。 - -![](./res/web-application.png) - -> 说明:相信有经验的读者会发现,这张图中其实还少了很多东西,例如反向代理服务器、数据库服务器、防火墙等,而且图中的每个节点在实际项目部署时可能是一组节点组成的集群。当然,如果你对这些没有什么概念也不要紧,继续下去就行了,后面会给大家一一讲解的。 - -| 术语 | 解释 | -| ------------- | ------------------------------------------------------------ | -| **URL/URI** | 统一资源定位符/统一资源标识符,网络资源的唯一标识 | -| **域名** | 与Web服务器地址对应的一个易于记忆的字符串名字 | -| **DNS** | 域名解析服务,可以将域名转换成对应的IP地址 | -| **IP地址** | 网络上的主机的身份标识,通过IP地址可以区分不同的主机 | -| **HTTP** | 超文本传输协议,构建在TCP之上的应用级协议,万维网数据通信的基础 | -| **反向代理** | 代理客户端向服务器发出请求,然后将服务器返回的资源返回给客户端 | -| **Web服务器** | 接受HTTP请求,然后返回HTML文件、纯文本文件、图像等资源给请求者 | -| **Nginx** | 高性能的Web服务器,也可以用作[反向代理](https://zh.wikipedia.org/wiki/%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86),[负载均衡](https://zh.wikipedia.org/wiki/%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1) 和 [HTTP缓存](https://zh.wikipedia.org/wiki/HTTP%E7%BC%93%E5%AD%98) | - -#### HTTP协议 - -这里我们稍微费一些笔墨来谈谈上面提到的HTTP。HTTP(超文本传输协议)是构建于TCP(传输控制协议)之上应用级协议,它利用了TCP提供的可靠的传输服务实现了Web应用中的数据交换。按照维基百科上的介绍,设计HTTP最初的目的是为了提供一种发布和接收[HTML](https://zh.wikipedia.org/wiki/HTML)页面的方法,也就是说这个协议是浏览器和Web服务器之间传输的数据的载体。关于这个协议的详细信息以及目前的发展状况,大家可以阅读阮一峰老师的[《HTTP 协议入门》](http://www.ruanyifeng.com/blog/2016/08/http.html)、[《互联网协议入门》](http://www.ruanyifeng.com/blog/2012/05/internet_protocol_suite_part_i.html)系列以及[《图解HTTPS协议》](http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html)进行了解。下图是我在四川省网络通信技术重点实验室学习和工作期间使用开源协议分析工具Ethereal(抓包工具WireShark的前身)截取的访问百度首页时的HTTP请求和响应的报文(协议数据),由于Ethereal截取的是经过网络适配器的数据,因此可以清晰的看到从物理链路层到应用层的协议数据。 - -HTTP请求(请求行+请求头+空行+[消息体]): - -![](./res/http-request.png) - -HTTP响应(响应行+响应头+空行+消息体): - -![](./res/http-response.png) - -> 说明:这两张图是在2009年9月10日截取的,但愿这两张如同泛黄的照片般的截图能帮助你了解HTTP到底是什么样子的。 - -### Django概述 - -Python的Web框架有上百个,比它的关键字还要多。所谓Web框架,就是用于开发Web服务器端应用的基础设施(通常指封装好的模块和一系列的工具)。事实上,即便没有Web框架,我们仍然可以通过socket或[CGI](https://zh.wikipedia.org/wiki/%E9%80%9A%E7%94%A8%E7%BD%91%E5%85%B3%E6%8E%A5%E5%8F%A3)来开发Web服务器端应用,但是这样做的成本和代价在实际开发中通常是不能接受的。通过Web框架,我们可以化繁为简,同时降低创建、更新、扩展应用程序的工作量。Python的Web框架中比较有名的有:Flask、Django、Tornado、Sanic、Pyramid、Bottle、Web2py、web.py等。 - -在基于Python的Web框架中,Django是所有重量级选手中最有代表性的一位,开发者可以基于Django快速的开发可靠的Web应用程序,因为它减少了Web开发中不必要的开销,对常用的设计和开发模式进行了封装,并对MVC架构提供了支持(MTV)。许多成功的网站和App都是基于Django框架构建的,国内比较有代表性的网站包括:知乎、豆瓣网、果壳网、搜狐闪电邮箱、101围棋网、海报时尚网、背书吧、堆糖、手机搜狐网、咕咚、爱福窝、果库等。 - -![](./res/mvc.png) - -Django诞生于2003年,它是一个在真正的应用中成长起来的项目,由劳伦斯出版集团旗下在线新闻网站的内容管理系统(CMS)研发团队编写(主要是Adrian Holovaty和Simon Willison),以比利时的吉普赛爵士吉他手Django Reinhardt来命名,在2005年夏天作为开源框架发布。使用Django能用很短的时间构建出功能完备的网站,因为它代替程序员完成了所有乏味和重复的劳动,剩下真正有意义的核心业务给程序员,这一点就是对DRY(Don't Repeat Yourself)理念的最好践行。 - -### 快速上手 - -#### 准备工作 - -1. 检查Python环境:Django 1.11需要Python 2.7或Python 3.4以上的版本;Django 2.0需要Python 3.4以上的版本;Django 2.1需要Python 3.5以上的版本。 - - > 说明:我自己平时使用macOS做开发,macOS和Linux平台使用的命令跟Windows平台有较大的区别,这一点在之前也有过类似的说明,如果使用Windows平台做开发,替换一下对应的命令即可。 - - ```Shell - $ python3 --version - ``` - - ```Shell - $ python3 - >>> import sys - >>> sys.version - >>> sys.version_info - ``` - -2. 创建项目文件夹并切换到该目录,例如我们要实例一个OA(办公自动化)项目。 - - ```Shell - $ mkdir oa - $ cd oa - ``` - -3. 创建并激活虚拟环境。 - - ```Shell - $ python3 -m venv venv - $ source venv/bin/activate - ``` - > 说明:上面使用了Python自带的venv模块完成了虚拟环境的创建,当然也可以使用virtualenv或pipenv这样的工具。要激活虚拟环境,在Windows环境下可以通过"venv/Scripts/activate"执行批处理文件来实现。 - -4. 更新包管理工具pip。 - - ```Shell - (venv)$ pip install -U pip - ``` - - 或 - - ```Shell - (venv)$ python -m pip install -U pip - ``` - > 注意:请注意终端提示符发生的变化,前面的`(venv)`说明我们已经进入虚拟环境,而虚拟环境下的python和pip已经是Python 3的解释器和包管理工具了。 - -5. 安装Django。 - - ```Shell - (venv)$ pip install django - ``` - - 或指定版本号来安装对应的Django的版本。 - - ```Shell - (venv)$ pip install django==2.1.8 - ``` - -6. 检查Django的版本。 - - ```Shell - (venv)$ python -m django --version - (venv)$ django-admin --version - ``` - - 或 - - ```Shell - (venv)$ python - >>> import django - >>> django.get_version() - ``` - 当然,也可以通过pip来查看安装的依赖库及其版本,如: - - ```Shell - (venv)$ pip freeze - (venv)$ pip list - ``` - - 下图展示了Django版本和Python版本的对应关系,如果在安装时没有指定版本号,将自动选择最新的版本(在写作这段内容时,Django最新的版本是2.2)。 - - | Django版本 | Python版本 | - | ---------- | ----------------------- | - | 1.8 | 2.7、3.2、3.3、3.4、3.5 | - | 1.9、1.10 | 2.7、3.4、3.5 | - | 1.11 | 2.7、3.4、3.5、3.6、3.7 | - | 2.0 | 3.4、3.5、3.6、3.7 | - | 2.1、2.2 | 3.5、3.6、3.7 | - -7. 使用`django-admin`创建项目,项目命名为oa。 - - ```Shell - (venv)$ django-admin startproject oa . - ``` - - > 注意:上面的命令最后的那个点,它表示在当前路径下创建项目。 - - 执行上面的命令后看看生成的文件和文件夹,它们的作用如下所示: - - - `manage.py`: 一个让你可以管理Django项目的工具程序。 - - `oa/__init__.py`:一个空文件,告诉Python解释器这个目录应该被视为一个Python的包。 - - `oa/settings.py`:Django项目的配置文件。 - - `oa/urls.py`:Django项目的URL声明(URL映射),就像是你的网站的“目录”。 - - `oa/wsgi.py`:项目运行在WSGI兼容Web服务器上的接口文件。 - - > 说明:WSGI全称是Web服务器网关接口,维基百科上给出的解释是“为Python语言定义的[Web服务器](https://zh.wikipedia.org/wiki/%E7%B6%B2%E9%A0%81%E4%BC%BA%E6%9C%8D%E5%99%A8)和[Web应用程序](https://zh.wikipedia.org/wiki/%E7%BD%91%E7%BB%9C%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F)或框架之间的一种简单而通用的接口”。 - -8. 启动服务器运行项目。 - - ```Shell - (venv)$ python manage.py runserver - ``` - - 在浏览器中输入访问我们的服务器,效果如下图所示。 - - ![](./res/django-index-1.png) - - - > 说明1:刚刚启动的是Django自带的用于开发和测试的服务器,它是一个用纯Python编写的轻量级Web服务器,但它并不是真正意义上的生产级别的服务器,千万不要将这个服务器用于和生产环境相关的任何地方。 - - > 说明2:用于开发的服务器在需要的情况下会对每一次的访问请求重新载入一遍Python代码。所以你不需要为了让修改的代码生效而频繁的重新启动服务器。然而,一些动作,比如添加新文件,将不会触发自动重新加载,这时你得自己手动重启服务器。 - - > 说明3:可以通过`python manage.py help`命令查看可用命令列表;在启动服务器时,也可以通过`python manage.py runserver 1.2.3.4:5678`来指定将服务器运行于哪个IP地址和端口。 - - > 说明4:可以通过Ctrl+C来终止服务器的运行。 - -9. 接下来我们修改项目的配置文件settings.py,Django是一个支持国际化和本地化的框架,因此刚才我们看到的默认首页也是支持国际化的,我们将默认语言修改为中文,时区设置为东八区。 - - ```Shell - (venv)$ vim oa/settings.py - ``` - - ```Python - # 此处省略上面的内容 - - # 设置语言代码 - LANGUAGE_CODE = 'zh-hans' - # 设置时区 - TIME_ZONE = 'Asia/Chongqing' - - # 此处省略下面的内容 - ``` - -10. 刷新刚才的页面。 - - ![](./res/django-index-2.png) - -#### 动态页面 - -1. 创建名为hrs(人力资源系统)的应用,一个Django项目可以包含一个或多个应用。 - - ```Shell - (venv)$ python manage.py startapp hrs - ``` - - 执行上面的命令会在当前路径下创建hrs目录,其目录结构如下所示: - - - `__init__.py`:一个空文件,告诉Python解释器这个目录应该被视为一个Python的包。 - - `admin.py`:可以用来注册模型,用于在Django的管理界面管理模型。 - - `apps.py`:当前应用的配置文件。 - - `migrations`:存放与模型有关的数据库迁移信息。 - - `__init__.py`:一个空文件,告诉Python解释器这个目录应该被视为一个Python的包。 - - `models.py`:存放应用的数据模型,即实体类及其之间的关系(MVC/MTV中的M)。 - - `tests.py`:包含测试应用各项功能的测试类和测试函数。 - - `views.py`:处理请求并返回响应的函数(MVC中的C,MTV中的V)。 - -2. 修改应用目录下的视图文件views.py。 - - ```Shell - (venv)$ vim hrs/views.py - ``` - - ```Python - from django.http import HttpResponse - - - def index(request): - return HttpResponse('

Hello, Django!

') - ``` - -3. 在应用目录创建一个urls.py文件并映射URL。 - - ```Shell - (venv)$ touch hrs/urls.py - (venv)$ vim hrs/urls.py - ``` - - ```Python - from django.urls import path - - from hrs import views - - urlpatterns = [ - path('', views.index, name='index'), - ] - ``` - > 说明:上面使用的`path`函数是Django 2.x中新添加的函数,除此之外还可以使用支持正则表达式的URL映射函数`re_path`函数;Django 1.x中是用名为`url`函数来设定URL映射。 - -4. 修改项目目录下的urls.py文件,对应用中设定的URL进行合并。 - - ```Shell - (venv) $ vim oa/urls.py - ``` - - ```Python - from django.contrib import admin - from django.urls import path, include - - urlpatterns = [ - path('admin/', admin.site.urls), - path('hrs/', include('hrs.urls')), - ] - ``` - - > 说明:上面的代码通过`include`函数将hrs应用中配置URL的文件包含到项目的URL配置中,并映射到`hrs/`路径下。 - -5. 重新运行项目,并打开浏览器中访问。 - - ```Shell - (venv)$ python manage.py runserver - ``` - -6. 修改views.py生成动态内容。 - - ```Shell - (venv)$ vim hrs/views.py - ``` - - ```Python - from io import StringIO - - from django.http import HttpResponse - - depts_list = [ - {'no': 10, 'name': '财务部', 'location': '北京'}, - {'no': 20, 'name': '研发部', 'location': '成都'}, - {'no': 30, 'name': '销售部', 'location': '上海'}, - ] - - - def index(request): - output = StringIO() - output.write('\n') - output.write('\n') - output.write('\t\n') - output.write('\t首页') - output.write('\n') - output.write('\n') - output.write('\t

部门信息

\n') - output.write('\t
\n') - output.write('\t\n') - output.write('\t\t\n') - output.write('\t\t\t\n') - output.write('\t\t\t\n') - output.write('\t\t\t\n') - output.write('\t\t\n') - for dept in depts_list: - output.write('\t\t\n') - output.write(f'\t\t\t\n') - output.write(f'\t\t\t\n') - output.write(f'\t\t\t\n') - output.write('\t\t\n') - output.write('\t
部门编号部门名称所在地
{dept["no"]}{dept["name"]}{dept["location"]}
\n') - output.write('\n') - output.write('\n') - return HttpResponse(output.getvalue()) - ``` - -7. 刷新页面查看程序的运行结果。 - - ![](./res/show-depts.png) - -#### 使用视图模板 - -上面通过拼接HTML代码的方式生成动态视图的做法在实际开发中是无能接受的,这一点大家一定能够想到。为了解决这个问题,我们可以提前准备一个模板页,所谓模板页就是一个带占位符的HTML页面,当我们将程序中获得的数据替换掉页面中的占位符时,一个动态页面就产生了。 - -我们可以用Django框架中template模块的Template类创建模板对象,通过模板对象的render方法实现对模板的渲染,在Django框架中还有一个名为`render`的便捷函数可以来完成渲染模板的操作。所谓的渲染就是用数据替换掉模板页中的占位符,当然这里的渲染称为后端渲染,即在服务器端完成页面的渲染再输出到浏览器中,这种做法的主要坏处是当并发访问量较大时,服务器会承受较大的负担,所以今天有很多的Web应用都使用了前端渲染,即服务器只提供所需的数据(通常是JSON格式),在浏览器中通过JavaScript获取这些数据并渲染到页面上,这个我们在后面的内容中会讲到。 - -1. 先回到manage.py文件所在的目录创建名为templates文件夹。 - - ```Shell - (venv)$ mkdir templates - ``` - -2. 创建模板页index.html。 - - ```Shell - (venv)$ touch templates/index.html - (venv)$ vim templates/index.html - ``` - ```HTML - - - - - 首页 - - -

部门信息

-
- - - - - - - {% for dept in depts_list %} - - - - - - {% endfor %} -
部门编号部门名称所在地
{{ dept.no }}{{ dept.name }}{{ dept.location }}
- - - ``` - 在上面的模板页中我们使用了`{{ greeting }}`这样的模板占位符语法,也使用了`{% for %}`这样的模板指令,这些都是Django模板语言(DTL)的一部分。如果对此不熟悉并不要紧,我们会在后续的内容中进一步的讲解,而且我们刚才也说到了,渲染页面还有更好的选择就是使用前端渲染,当然这是后话。 - -3. 回到应用目录,修改views.py文件。 - - ```Shell - (venv)$ vim hrs/views.py - ``` - - ```Python - from django.shortcuts import render - - depts_list = [ - {'no': 10, 'name': '财务部', 'location': '北京'}, - {'no': 20, 'name': '研发部', 'location': '成都'}, - {'no': 30, 'name': '销售部', 'location': '上海'}, - ] - - - def index(request): - return render(request, 'index.html', {'depts_list': depts_list}) - ``` - - > 说明:Django框架通过shortcuts模块的便捷函数`render`简化了渲染模板的操作,有了这个函数,就不用先创建`Template`对象再去调用`render`方法。。 - - 到此为止,我们还没有办法让views.py中的`render`函数找到模板文件index.html,为此我们需要修改settings.py文件,配置模板文件所在的路径。 - -4. 切换到项目目录修改settings.py文件。 - - ```Shell - (venv)$ vim oa/settings.py - ``` - - ```Python - # 此处省略上面的内容 - - TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, - ] - - # 此处省略下面的内容 - ``` - -5. 重新运行项目或直接刷新页面查看结果。 - - ```Shell - (venv)$ python manage.py runserver - ``` - - -### 总结 - -至此,我们已经利用Django框架完成了一个非常小的Web应用,虽然它并没有任何的实际价值,但是可以通过这个项目对Django框架有一个感性的认识。当然,实际开发中我们可以用PyCharm来创建项目,如果使用专业版的PyCharm,可以直接创建Django项目。使用PyCharm的好处在于编写代码时可以获得代码提示、错误修复、自动导入等功能,从而提升开发效率,但是专业版的PyCharm需要按年支付相应的费用,社区版的PyCharm中并未包含对Django框架直接的支持,但是我们仍然可以使用它来创建Django项目,只是在使用上没有专业版的方便。关于PyCharm的使用,可以参考[《玩转PyCharm》](../玩转PyCharm.md)一文。此外,Django最好的学习资料肯定是它的[官方文档](https://docs.djangoproject.com/zh-hans/2.0/),当然图灵社区出版的[《Django基础教程》](http://www.ituring.com.cn/book/2630)也是非常适合初学者的入门级读物。 - diff --git a/Day41-55/42.深入模型.md b/Day41-55/42.深入模型.md index 3ba9035..dc9b86b 100644 --- a/Day41-55/42.深入模型.md +++ b/Day41-55/42.深入模型.md @@ -1,20 +1,76 @@ ## 深入模型 -在上一个章节中,我们提到了Django是基于MVC架构的Web框架,MVC架构追求的是“模型”和“视图”的解耦合。所谓“模型”说得更直白一些就是数据(的表示),所以通常也被称作“数据模型”。在实际的项目中,数据模型通常通过数据库实现持久化操作,而关系型数据库在过去和当下都是持久化的首选方案,下面我们以MySQL为例来说明如何使用关系型数据库来实现持久化操作。 +在上一个章节中,我们提到了Django是基于MVC架构的Web框架,MVC架构追求的是“模型”和“视图”的解耦合。所谓“模型”说得更直白一些就是数据(的表示),所以通常也被称作“数据模型”。在实际的项目中,数据模型通常通过数据库实现持久化操作,而关系型数据库在过去和当下都是持久化的首选方案,下面我们通过完成一个投票项目来讲解和模型相关的知识点。投票项目的首页会展示某在线教育平台所有的学科;点击学科可以查看到该学科的老师及其信息;用户登录后在查看老师的页面为老师投票,可以投赞成票和反对票;未登录的用户可以通过登录页进行登录;尚未注册的用户可以通过注册页输入个人信息进行注册。在这个项目中,我们使用MySQL数据库来实现数据持久化操作。 + +### 创建项目和应用 + +我们首先创建Django项目`vote`并为其添加虚拟环境和依赖项。接下来,在项目下创建名为`polls`的应用和保存模板页的文件夹`tempaltes`,项目文件夹的结构如下所示。 + +![](res/pycharm-vote-project.png) + +根据上面描述的项目需求,我们准备了四个静态页面,分别是展示学科的页面`subjects.html`,显示学科老师的页面`teachers.html`,登录页面`login.html`,注册页面`register.html`,稍后我们会将静态页修改为Django项目所需的模板页。 ### 配置关系型数据库MySQL -我们继续来完善上一个章节中的OA项目,首先从配置项目使用的数据库开始。 +1. 在MySQL中创建数据库,创建用户,授权用户访问该数据库。 -1. 修改项目的settings.py文件,首先将我们之前创建的应用hrs添加已安装的项目中,然后配置MySQL作为持久化方案。 - - ```Shell - (venv)$ vim oa/settings.py + ```SQL + create database vote default charset utf8; + create user 'hellokitty'@'%' identified by 'Hellokitty.618'; + grant all privileges on vote.* to 'hellokitty'@'%'; + flush privileges; ``` - ```Python - # 此处省略上面的代码 +2. 在MySQL中创建保存学科和老师信息的二维表(保存用户信息的表稍后处理)。 + + ```SQL + use vote; + -- 创建学科表 + create table `tb_subject` + ( + `no` integer auto_increment comment '学科编号', + `name` varchar(50) not null comment '学科名称', + `intro` varchar(1000) not null default '' comment '学科介绍', + `is_hot` boolean not null default 0 comment '是不是热门学科', + primary key (`no`) + ); + -- 创建老师表 + create table `tb_teacher` + ( + `no` integer auto_increment comment '老师编号', + `name` varchar(20) not null comment '老师姓名', + `sex` boolean not null default 1 comment '老师性别', + `birth` date not null comment '出生日期', + `intro` varchar(1000) not null default '' comment '老师介绍', + `photo` varchar(255) not null default '' comment '老师照片', + `gcount` integer not null default 0 comment '好评数', + `bcount` integer not null default 0 comment '差评数', + `sno` integer not null comment '所属学科', + primary key (`no`), + foreign key (`sno`) references `tb_subject` (`no`) + ); + ``` + +3. 在虚拟环境中安装连接MySQL数据库所需的依赖项。 + + ```Bash + pip install mysqlclient + ``` + + > **说明**:如果因为某些原因无法安装`mysqlclient`三方库,可以使用它的替代品`pymysql`,`pymysql`是用纯Python开发的连接MySQL的Python库,安装更容易成功,但是需要在Django项目文件夹的`__init__.py`中添加如下所示的代码。 + > + > ```Python + > import pymysql + > + > pymysql.install_as_MySQLdb() + > ``` + > + > 如果使用Django 2.2及以上版本,还会遇到PyMySQL跟Django框架的兼容性问题,兼容性问题会导致项目无法运行,需要按照GitHub上PyMySQL仓库[Issues](https://github.com/PyMySQL/PyMySQL/issues/790)中提供的方法进行处理。总体来说,使用`pymysql`会比较麻烦,强烈建议大家首选安装`mysqlclient`。 + +4. 修改项目的settings.py文件,首先将我们创建的应用`polls`添加已安装的项目(`INSTALLED_APPS`)中,然后配置MySQL作为持久化方案。 + + ```Python INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', @@ -22,290 +78,113 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'hrs', + 'polls', ] DATABASES = { 'default': { + # 数据库引擎配置 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'oa', - 'HOST': '127.0.0.1', + # 数据库的名字 + 'NAME': 'vote', + # 数据库服务器的IP地址(本机可以写localhost或127.0.0.1) + 'HOST': 'localhost', + # 启动MySQL服务的端口号 'PORT': 3306, - 'USER': 'root', - 'PASSWORD': '123456', + # 数据库用户名和口令 + 'USER': 'hellokitty', + 'PASSWORD': 'Hellokitty.618', + # 数据库使用的字符集 + 'CHARSET': 'utf8', + # 数据库时间日期的时区设定 + 'TIME_ZONE': 'Asia/Chongqing', } } - - # 此处省略下面的代码 ``` 在配置ENGINE属性时,常用的可选值包括: - `'django.db.backends.sqlite3'`:SQLite嵌入式数据库。 - `'django.db.backends.postgresql'`:BSD许可证下发行的开源关系型数据库产品。 - - `'django.db.backends.mysql'`:转手多次目前属于甲骨文公司的经济高效的数据库产品。 - - `'django.db.backends.oracle'`:甲骨文公司的关系型数据库旗舰产品。 + - `'django.db.backends.mysql'`:甲骨文公司经济高效的数据库产品。 + - `'django.db.backends.oracle'`:甲骨文公司关系型数据库旗舰产品。 其他的配置可以参考官方文档中[数据库配置](https://docs.djangoproject.com/zh-hans/2.0/ref/databases/#third-party-notes)的部分。 - NAME属性代表数据库的名称,如果使用SQLite它对应着一个文件,在这种情况下NAME的属性值应该是一个绝对路径;使用其他关系型数据库,则要配置对应的HOST(主机)、PORT(端口)、USER(用户名)、PASSWORD(口令)等属性。 +5. Django框架提供了ORM来解决数据持久化问题,ORM翻译成中文叫“对象关系映射”。因为Python是面向对象的编程语言,我们在Python程序中使用对象模型来保存数据,而关系型数据库使用关系模型,用二维表来保存数据,这两种模型并不匹配。使用ORM是为了实现对象模型到关系模型的**双向转换**,这样就不用在Python代码中书写SQL语句和游标操作,因为这些都会由ORM自动完成。利用Django的ORM,我们可以直接将刚才创建的学科表和老师表变成Django中的模型类。 -2. 安装Python操作MySQL的依赖库,Python 3中通常使用PyMySQL,Python 2中通常用MySQLdb。 - - ```Shell - (venv)$ pip install pymysql + ```Bash + python manage.py inspectdb > polls/models.py ``` - 如果使用Python 3需要修改**项目目录**下的`__init__.py`文件并加入如下所示的代码,这段代码的作用是将PyMySQL视为MySQLdb来使用,从而避免Django找不到连接MySQL的客户端工具而询问你:“Did you install mysqlclient? ”(你安装了mysqlclient吗?)。 - - ```Python - import pymysql - - pymysql.install_as_MySQLdb() - ``` - -3. 如果之前没有为应用程序创建数据库,那么现在是时候创建名为oa的数据库了。在MySQL中创建数据库的SQL语句如下所示: - - ```SQL - create database oa default charset utf8; - ``` - -4. Django框架本身有自带的数据模型,我们稍后会用到这些模型,为此我们先做一次迁移操作。所谓迁移,就是根据模型自动生成关系数据库中的二维表,命令如下所示: - - ```Shell - (venv)$ python manage.py migrate - Operations to perform: - Apply all migrations: admin, auth, contenttypes, sessions - Running migrations: - Applying contenttypes.0001_initial... OK - Applying auth.0001_initial... OK - Applying admin.0001_initial... OK - Applying admin.0002_logentry_remove_auto_add... OK - Applying contenttypes.0002_remove_content_type_name... OK - Applying auth.0002_alter_permission_name_max_length... OK - Applying auth.0003_alter_user_email_max_length... OK - Applying auth.0004_alter_user_username_opts... OK - Applying auth.0005_alter_user_last_login_null... OK - Applying auth.0006_require_contenttypes_0002... OK - Applying auth.0007_alter_validators_add_error_messages... OK - Applying auth.0008_alter_user_username_max_length... OK - Applying auth.0009_alter_user_last_name_max_length... OK - Applying sessions.0001_initial... OK - ``` - -5. 接下来,我们为自己的应用创建数据模型。如果要在hrs应用中实现对部门和员工的管理,我们可以先创建部门和员工数据模型,代码如下所示。 - - ```Shell - (venv)$ vim hrs/models.py - ``` + 我们可以对自动生成的模型类稍作调整,代码如下所示。 ```Python from django.db import models - class Dept(models.Model): - """部门类""" - - no = models.IntegerField(primary_key=True, db_column='dno', verbose_name='部门编号') - name = models.CharField(max_length=20, db_column='dname', verbose_name='部门名称') - location = models.CharField(max_length=10, db_column='dloc', verbose_name='部门所在地') + class Subject(models.Model): + no = models.AutoField(primary_key=True, verbose_name='编号') + name = models.CharField(max_length=50, verbose_name='名称') + intro = models.CharField(max_length=1000, verbose_name='介绍') + is_hot = models.BooleanField(verbose_name='是否热门') class Meta: - db_table = 'tb_dept' + managed = False + db_table = 'tb_subject' - class Emp(models.Model): - """员工类""" - - no = models.IntegerField(primary_key=True, db_column='eno', verbose_name='员工编号') - name = models.CharField(max_length=20, db_column='ename', verbose_name='员工姓名') - job = models.CharField(max_length=10, verbose_name='职位') - # 多对一外键关联(自参照) - mgr = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, verbose_name='主管') - sal = models.DecimalField(max_digits=7, decimal_places=2, verbose_name='月薪') - comm = models.DecimalField(max_digits=7, decimal_places=2, null=True, blank=True, verbose_name='补贴') - # 多对一外键关联(参照部门模型) - dept = models.ForeignKey(Dept, db_column='dno', on_delete=models.PROTECT, verbose_name='所在部门') + class Teacher(models.Model): + no = models.AutoField(primary_key=True, verbose_name='编号') + name = models.CharField(max_length=20, verbose_name='姓名') + sex = models.BooleanField(default=True, verbose_name='性别') + birth = models.DateField(verbose_name='出生日期') + intro = models.CharField(max_length=1000, verbose_name='个人介绍') + photo = models.ImageField(max_length=255, verbose_name='照片') + good_count = models.IntegerField(default=0, db_column='gcount', verbose_name='好评数') + bad_count = models.IntegerField(default=0, db_column='bcount', verbose_name='差评数') + subject = models.ForeignKey(Subject, models.DO_NOTHING, db_column='sno') class Meta: - db_table = 'tb_emp' + managed = False + db_table = 'tb_teacher' ``` - > 说明:上面定义模型时使用了字段类及其属性,其中IntegerField对应数据库中的integer类型,CharField对应数据库的varchar类型,DecimalField对应数据库的decimal类型,ForeignKey用来建立多对一外键关联。字段属性primary_key用于设置主键,max_length用来设置字段的最大长度,db_column用来设置数据库中与字段对应的列,verbose_name则设置了Django后台管理系统中该字段显示的名称。如果对这些东西感到很困惑也不要紧,文末提供了字段类、字段属性、元数据选项等设置的相关说明,不清楚的读者可以稍后查看对应的参考指南。 - -6. 再次执行迁移操作,先通过模型生成迁移文件,再执行迁移创建二维表。 - - ```Shell - (venv)$ python manage.py makemigrations hrs - Migrations for 'hrs': - hrs/migrations/0001_initial.py - - Create model Dept - - Create model Emp - (venv)$ python manage.py migrate - Operations to perform: - Apply all migrations: admin, auth, contenttypes, hrs, sessions - Running migrations: - Applying hrs.0001_initial... OK - ``` - - 执行完数据模型迁移操作之后,可以在通过图形化的MySQL客户端工具查看到E-R图(实体关系图)。 - - ![](./res/er-graph.png) - -### 利用Django后台管理模型 - -Django框架有自带的后台管理系统来实现对模型的管理。虽然实际应用中,这个后台可能并不能满足我们的需求,但是在学习Django框架时,我们暂时可以利用Django自带的后台管理系统来管理我们的模型,同时也可以了解一个项目的后台管理系统到底需要哪些功能。 - -1. 创建超级管理员账号。 - - ```Shell - (venv)$ python manage.py createsuperuser - Username (leave blank to use 'hao'): jackfrued - Email address: jackfrued@126.com - Password: - Password (again): - Superuser created successfully. - ``` - -2. 启动Web服务器,登录后台管理系统。 - - ```Shell - (venv)$ python manage.py runserver - ``` - - 访问,会来到如下图所示的登录界面。 - - ![](./res/admin-login.png) - - 登录后进入管理员操作平台。 - - ![](./res/admin-welcome.png) - - 至此我们还没有看到之前创建的模型类,需要在应用的admin.py文件中模型进行注册。 - -3. 注册模型类。 - - ```Shell - (venv)$ vim hrs/admin.py - ``` - - ```Python - from django.contrib import admin - from hrs.models import Emp, Dept - - admin.site.register(Dept) - admin.site.register(Emp) - ``` - - 注册模型类后,就可以在后台管理系统中看到它们。 - - ![](./res/admin-model.png) - -4. 对模型进行CRUD操作。 - - 可以在管理员平台对模型进行C(新增)、R(查看)、U(更新)、D(删除)操作,如下图所示。 - - - 添加新的部门。 - - ![](./res/admin-model-create.png) - - - 查看所有部门。 - - ![](./res/admin-model-read.png) - - - 更新和删除部门。 - - ![](./res/admin-model-delete-and-update.png) - -5. 注册模型管理类。 - - 可能大家已经注意到了,刚才在后台查看部门信息的时候,显示的部门信息并不直观,为此我们再修改admin.py文件,通过注册模型管理类,可以在后台管理系统中更好的管理模型。 - - ```Python - from django.contrib import admin - - from hrs.models import Emp, Dept - - - class DeptAdmin(admin.ModelAdmin): - - list_display = ('no', 'name', 'location') - ordering = ('no', ) - - - class EmpAdmin(admin.ModelAdmin): - - list_display = ('no', 'name', 'job', 'mgr', 'sal', 'comm', 'dept') - search_fields = ('name', 'job') - - - admin.site.register(Dept, DeptAdmin) - admin.site.register(Emp, EmpAdmin) - ``` - - ![](./res/admin-model-depts.png) - - ![](./res/admin-model-emps.png) - - 为了更好的查看模型数据,可以为Dept和Emp两个模型类添加`__str__`魔法方法。 - - ```Python - from django.db import models - - - class Dept(models.Model): - """部门类""" - - # 此处省略上面的代码 - - def __str__(self): - return self.name - - # 此处省略下面的代码 - - - class Emp(models.Model): - """员工类""" - - # 此处省略上面的代码 - - def __str__(self): - return self.name - - # 此处省略下面的代码 - ``` - - 修改代码后刷新查看Emp模型的页面,效果如下图所示。 - - ![](./res/admin-model-emps-modified.png) + > **说明**:模型类都直接或间接继承自`Model`类,模型类跟关系型数据库的二维表对应,模型对象跟表中的记录对应,模型对象的属性跟表中的字段对应。如果对上面模型类的属性定义不是特别理解,可以看看本文后面提供的“模型定义参考”部分的内容。 ### 使用ORM完成模型的CRUD操作 -在了解了Django提供的模型管理平台之后,我们来看看如何从代码层面完成对模型的CRUD(Create / Read / Update / Delete)操作。我们可以通过manage.py开启Shell交互式环境,然后使用Django内置的ORM框架对模型进行CRUD操作。 +有了Django框架的ORM,我们可以直接使用面向对象的方式来实现对数据的CRUD(增删改查)操作。我们可以在PyCharm的终端中输入下面的命令进入到Django项目的交互式环境,然后尝试对模型的操作。 -```Shell -(venv)$ python manage.py shell -Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) -[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin -Type "help", "copyright", "credits" or "license" for more information. -(InteractiveConsole) ->>> +```Bash +python manage.py shell ``` #### 新增 -```Shell ->>> from hrs.models import Dept, Emp ->>> ->>> dept = Dept(40, '研发2部', '深圳') ->>> dept.save() +```Python +from polls.models import Subject + +subject1 = Subject(name='Python全栈开发', intro='当下最热门的学科', is_hot=True) +subject1.save() +subject2 = Subject(name='全栈软件测试', intro='学习自动化测试的学科', is_hot=False) +subject2.save() +subject3 = Subject(name='JavaEE分布式开发', intro='基于Java语言的服务器应用开发', is_hot=True) +``` + +#### 删除 + +```Python +subject = Subject.objects.get(no=2) +subject.delete() ``` #### 更新 ```Shell ->>> dept.name = '研发3部' ->>> dept.save() +subject = Subject.objects.get(no=1) +subject.name = 'Python全栈+人工智能' +subject.save() ``` #### 查询 @@ -313,89 +192,364 @@ Type "help", "copyright", "credits" or "license" for more information. 1. 查询所有对象。 ```Shell ->>> Dept.objects.all() -, , , ]> +Subjects.objects.all() ``` 2. 过滤数据。 ```Shell ->>> Dept.objects.filter(name='研发3部') # 查询部门名称为“研发3部”的部门 -]> ->>> ->>> Dept.objects.filter(name__contains='研发') # 查询部门名称包含“研发”的部门(模糊查询) -, ]> ->>> ->>> Dept.objects.filter(no__gt=10).filter(no__lt=40) # 查询部门编号大于10小于40的部门 -, ]> ->>> ->>> Dept.objects.filter(no__range=(10, 30)) # 查询部门编号在10到30之间的部门 -, , ]> +# 查询名称为“Python全栈+人工智能”的学科 +Subject.objects.filter(name='Python全栈+人工智能') + +# 查询名称包含“全栈”的学科(模糊查询) +Subject.objects.filter(name__contains='全栈') +Subject.objects.filter(name__startswith='全栈') +Subject.objects.filter(name__endswith='全栈') + +# 查询所有热门学科 +Subject.objects.filter(is_hot=True) + +# 查询编号大于3小于10的学科 +Subject.objects.filter(no__gt=3).filter(no__lt=10) +Subject.objects.filter(no__gt=3, no__lt=10) + +# 查询编号在3到7之间的学科 +Subject.objects.filter(no__ge=3, no__le=7) +Subject.objects.filter(no__range=(3, 7)) ``` 3. 查询单个对象。 ```Shell ->>> Dept.objects.get(pk=10) - ->>> ->>> Dept.objects.get(no=20) - ->>> ->>> Dept.objects.get(no__exact=30) - ->>> ->>> Dept.objects.filter(no=10).first() - +# 查询主键为1的学科 +Subject.objects.get(pk=1) +Subject.objects.get(no=1) +Subject.objects.filter(no=1).first() +Subject.objects.filter(no=1).last() ``` -4. 排序数据。 +4. 排序。 ```Shell ->>> Dept.objects.order_by('no') # 查询所有部门按部门编号升序排列 -, , , ]> ->>> ->>> Dept.objects.order_by('-no') # 查询所有部门按部门编号降序排列 -, , , ]> +# 查询所有学科按编号升序排列 +Subject.objects.order_by('no') +# 查询所有部门按部门编号降序排列 +Subject.objects.order_by('-no') ``` -5. 数据切片(分页查询)。 +5. 切片(分页查询)。 ```Shell ->>> Dept.objects.order_by('no')[0:2] # 按部门编号排序查询1~2部门 -, ]> ->>> ->>> Dept.objects.order_by('no')[2:4] # 按部门编号排序查询3~4部门 -, ]> +# 按编号从小到大查询前3个学科 +Subject.objects.order_by('no')[:3] ``` -6. 高级查询。 +6. 计数。 + +```Python +# 查询一共有多少个学科 +Subject.objects.count() +``` + +7. 高级查询。 ```Shell ->>> Emp.objects.filter(dept__no=10) # 根据部门编号查询该部门的员工 -, , ]> ->>> ->>> Emp.objects.filter(dept__name__contains='销售') # 查询名字包含“销售”的部门的员工 -]> ->>> ->>> Dept.objects.get(pk=10).emp_set.all() # 通过部门反查部门所有的员工 -, , ]> +# 查询编号为1的学科的老师 +Teacher.objects.filter(subject__no=1) +Subject.objects.get(pk=1).teacher_set.all() + +# 查询学科名称有“全栈”二字的学科的老师 +Teacher.objects.filter(subject__name__contains='全栈') ``` -> 说明1:由于员工与部门之间存在多对一外键关联,所以也能通过部门反向查询该部门的员工(从一对多关系中“一”的一方查询“多”的一方),反向查询属性默认的名字是`类名小写_set`(如上面例子中的`emp_set`),当然也可以在创建模型时通过`ForeingKey`的`related_name`属性指定反向查询属性的名字。如果不希望执行反向查询可以将`related_name`属性设置为`'+'`或以`'+'`开头的字符串。 +> **说明1**:由于老师与学科之间存在多对一外键关联,所以能通过学科反向查询到该学科的老师(从一对多关系中“一”的一方查询“多”的一方),反向查询属性默认的名字是`类名小写_set`(如上面例子中的`teacher_set`),当然也可以在创建模型时通过`ForeingKey`的`related_name`属性指定反向查询属性的名字。如果不希望执行反向查询可以将`related_name`属性设置为`'+'`或者以`'+'`开头的字符串。 -> 说明2:查询多个对象的时候返回的是QuerySet对象,QuerySet使用了惰性查询,即在创建QuerySet对象的过程中不涉及任何数据库活动,等真正用到对象时(求值QuerySet)才向数据库发送SQL语句并获取对应的结果,这一点在实际开发中需要引起注意! +> **说明2**:ORM查询多个对象时会返回QuerySet对象,QuerySet使用了惰性查询,即在创建QuerySet对象的过程中不涉及任何数据库活动,等真正用到对象时(对QuerySet求值)才向数据库发送SQL语句并获取对应的结果,这一点在实际开发中需要引起注意! -> 说明3:可以在QuerySet上使用`update()`方法一次更新多个对象。 +> **说明3**:如果希望更新多条数据,不用先逐一获取模型对象再修改对象属性,可以直接使用QuerySet对象的`update()`方法一次性更新多条数据。 -#### 删除 -```Shell ->>> Dept.objects.get(pk=40).delete() -(1, {'hrs.Dept': 1}) -``` +### 利用Django后台管理模型 -### Django模型最佳实践 +在创建好模型类之后,可以通过Django框架自带的后台管理应用(`admin`应用)实现对模型的管理。虽然实际应用中,这个后台可能并不能满足我们的需求,但是在学习Django框架时,我们可以利用`admin`应用来管理我们的模型,同时也通过它来了解一个项目的后台管理系统需要哪些功能。使用Django自带的`admin`应用步骤如下所示。 + +1. 将`admin`应用所需的表迁移到数据库中。`admin`应用本身也需要数据库的支持,而且在`admin`应用中已经定义好了相关的数据模型类,我们只需要通过模型迁移操作就能自动在数据库中生成所需的二维表。 + + ```Bash + python manage.py migrate + ``` + +2. 创建访问`admin`应用的超级用户账号,这里需要输入用户名、邮箱和口令。 + + ```Shell + python manage.py createsuperuser + ``` + + > **说明**:输入口令时没有回显也不能退格,需要一气呵成完成输入。 + +3. 运行项目,在浏览器中访问`http://127.0.0.1:8000/admin`,输入刚才创建的超级用户账号和密码进行登录。 + + ![](/Users/Hao/Desktop/Python-100-Days/Day41-55/res/django-admin-login.png) + + 登录后进入管理员操作平台。 + + ![](res/django-admin-apps.png) + + 注意,我们暂时还没能在`admin`应用中看到之前创建的模型类,为此需要在`polls`应用的`admin.py`文件中对需要管理的模型进行注册。 + +4. 注册模型类。 + + ```Python + from django.contrib import admin + + from polls.models import Subject, Teacher + + admin.site.register(Subject) + admin.site.register(Teacher) + ``` + + 注册模型类后,就可以在后台管理系统中看到它们。 + + ![](./res/django-admin-models.png) + +5. 对模型进行CRUD操作。 + + 可以在管理员平台对模型进行C(新增)、R(查看)、U(更新)、D(删除)操作,如下图所示。 + + - 添加学科。 + + ![](res/django-admin-add-model.png) + + - 查看所有学科。 + + ![](res/django-admin-view-models.png) + + - 删除和更新学科。 + + ![](res/django-admin-delete-update-model.png) + +6. 注册模型管理类。 + + 可能大家已经注意到了,刚才在后台查看部门信息的时候,显示的部门信息并不直观,为此我们再修改`admin.py`文件,通过注册模型管理类,可以在后台管理系统中更好的管理模型。 + + ```Python + from django.contrib import admin + + from polls.models import Subject, Teacher + + + class SubjectModelAdmin(admin.ModelAdmin): + list_display = ('no', 'name', 'intro', 'is_hot') + search_fields = ('name', ) + ordering = ('no', ) + + + class TeacherModelAdmin(admin.ModelAdmin): + list_display = ('no', 'name', 'sex', 'birth', 'good_count', 'bad_count', 'subject') + search_fields = ('name', ) + ordering = ('no', ) + + + admin.site.register(Subject, SubjectModelAdmin) + admin.site.register(Teacher, TeacherModelAdmin) + ``` + + ![](res/django-admin-view-models-subject.png) + + ![](res/django-admin-view-models-teacher.png) + + 为了更好的查看模型,我们为`Subject`类添加`__str__`魔法方法,并在该方法中返回学科名字。这样在如上图所示的查看老师的页面上显示老师所属学科时,就不再是`Subject object(1)`这样晦涩的信息,而是学科的名称。 + +### 实现学科页和老师页效果 + +1. 修改`polls/views.py`文件,编写视图函数实现对学科页和老师页的渲染。 + + ```Python + from django.shortcuts import render, redirect + + from polls.models import Subject, Teacher + + + def show_subjects(request): + subjects = Subject.objects.all().order_by('no') + return render(request, 'subjects.html', {'subjects': subjects}) + + + def show_teachers(request): + try: + sno = int(request.GET.get('sno')) + teachers = [] + if sno: + subject = Subject.objects.only('name').get(no=sno) + teachers = Teacher.objects.filter(subject=subject).order_by('no') + return render(request, 'teachers.html', { + 'subject': subject, + 'teachers': teachers + }) + except (ValueError, Subject.DoesNotExist): + return redirect('/') + ``` + +2. 修改`templates/subjects.html`和`templates/teachers.html`模板页。 + + `subjects.html` + + ```HTML + + + + + 学科信息 + + + +
+ +

扣丁学堂所有学科

+
+
+ {% for subject in subjects %} +
+
+ {{ subject.name }} + {% if subject.is_hot %} + + {% endif %} +
+
{{ subject.intro }}
+
+ {% endfor %} +
+
+ + + ``` + + `teachers.html` + + ```HTML + + + + + 老师信息 + + + +
+

{{ subject.name }}学科的老师信息

+
+ {% if not teachers %} +

暂无该学科老师信息

+ {% endif %} + {% for teacher in teachers %} +
+
+ +
+
+
+ 姓名:{{ teacher.name }} + 性别:{{ teacher.sex | yesno:'男,女' }} + 出生日期:{{ teacher.birth | date:'Y年n月j日'}} +
+
{{ teacher.intro }}
+
+ 好评 ({{ teacher.good_count }}) +      + 差评 {{ teacher.bad_count }}) +
+
+
+ {% endfor %} + 返回首页 +
+ + + ``` + +3. 修改`vote/urls.py`文件,实现映射URL。 + + ```Python + from django.contrib import admin + from django.urls import path + + from polls.views import show_subjects, show_teachers + + urlpatterns = [ + path('admin/', admin.site.urls), + path('', show_subjects), + path('teachers/', show_teachers), + ] + ``` + +到此为止,页面上需要的图片(静态资源)还没有能够正常展示,我们在下一章节中为大家介绍如何处理模板页上的需要的静态资源。 + +### 补充内容 + +#### Django模型最佳实践 1. 正确的为模型和关系字段命名。 2. 设置适当的`related_name`属性。 @@ -412,11 +566,11 @@ Type "help", "copyright", "credits" or "license" for more information. 13. 定义`__str__`方法。 14. 不要将数据文件放在同一个目录中。 -> 说明:以上内容来自于STEELKIWI网站的[*Best Practice working with Django models in Python*](https://steelkiwi.com/blog/best-practices-working-django-models-python/),有兴趣的小伙伴可以阅读原文。 +> **说明**:以上内容来自于STEELKIWI网站的[*Best Practice working with Django models in Python*](https://steelkiwi.com/blog/best-practices-working-django-models-python/),有兴趣的小伙伴可以阅读原文。 -### 模型定义参考 +#### 模型定义参考 -#### 字段 +##### 字段 对字段名称的限制 @@ -425,114 +579,103 @@ Type "help", "copyright", "credits" or "license" for more information. Django模型字段类 -| 字段类 | 说明 | -| --------------------- | ------------------------------------------------------------ | -| AutoField |自增ID字段 | -| BigIntegerField |64位有符号整数 | -| BinaryField | 存储二进制数据的字段,对应Python的bytes类型 | -| BooleanField | 存储True或False | -| CharField | 长度较小的字符串 | -| DateField | 存储日期,有auto_now和auto_now_add属性 | -| DateTimeField | 存储日期和日期,两个附加属性同上 | -| DecimalField |存储固定精度小数,有max_digits(有效位数)和decimal_places(小数点后面)两个必要的参数 | -| DurationField |存储时间跨度 | -| EmailField | 与CharField相同,可以用EmailValidator验证 | -| FileField | 文件上传字段 | -| FloatField | 存储浮点数 | -| ImageField | 其他同FileFiled,要验证上传的是不是有效图像 | -| IntegerField | 存储32位有符号整数。 | -| GenericIPAddressField | 存储IPv4或IPv6地址 | -| NullBooleanField | 存储True、False或null值 | -| PositiveIntegerField | 存储无符号整数(只能存储正数) | -| SlugField | 存储slug(简短标注) | -| SmallIntegerField | 存储16位有符号整数 | -| TextField | 存储数据量较大的文本 | -| TimeField | 存储时间 | -| URLField | 存储URL的CharField | -| UUIDField | 存储全局唯一标识符 | +| 字段类 | 说明 | +| ----------------------- | ------------------------------------------------------------ | +| `AutoField` | 自增ID字段 | +| `BigIntegerField` | 64位有符号整数 | +| `BinaryField` | 存储二进制数据的字段,对应Python的`bytes`类型 | +| `BooleanField` | 存储`True`或`False` | +| `CharField` | 长度较小的字符串 | +| `DateField` | 存储日期,有`auto_now`和`auto_now_add`属性 | +| `DateTimeField` | 存储日期和日期,两个附加属性同上 | +| `DecimalField` | 存储固定精度小数,有`max_digits`(有效位数)和`decimal_places`(小数点后面)两个必要的参数 | +| `DurationField` | 存储时间跨度 | +| `EmailField` | 与`CharField`相同,可以用`EmailValidator`验证 | +| `FileField` | 文件上传字段 | +| `FloatField` | 存储浮点数 | +| `ImageField` | 其他同`FileFiled`,要验证上传的是不是有效图像 | +| `IntegerField` | 存储32位有符号整数。 | +| `GenericIPAddressField` | 存储IPv4或IPv6地址 | +| `NullBooleanField` | 存储`True`、`False`或`null`值 | +| `PositiveIntegerField` | 存储无符号整数(只能存储正数) | +| `SlugField` | 存储slug(简短标注) | +| `SmallIntegerField` | 存储16位有符号整数 | +| `TextField` | 存储数据量较大的文本 | +| `TimeField` | 存储时间 | +| `URLField` | 存储URL的`CharField` | +| `UUIDField` | 存储全局唯一标识符 | -#### 字段属性 +##### 字段属性 通用字段属性 -| 选项 | 说明 | -| -------------- | ------------------------------------------------------------ | -| null | 数据库中对应的字段是否允许为NULL,默认为False | -| blank | 后台模型管理验证数据时,是否允许为NULL,默认为False | -| choices | 设定字段的选项,各元组中的第一个值是设置在模型上的值,第二值是人类可读的值 | -| db_column | 字段对应到数据库表中的列名,未指定时直接使用字段的名称 | -| db_index | 设置为True时将在该字段创建索引 | -| db_tablespace | 为有索引的字段设置使用的表空间,默认为DEFAULT_INDEX_TABLESPACE | -| default | 字段的默认值 | -| editable | 字段在后台模型管理或ModelForm中是否显示,默认为True | -| error_messages | 设定字段抛出异常时的默认消息的字典,其中的键包括null、blank、invalid、invalid_choice、unique和unique_for_date | -| help_text | 表单小组件旁边显示的额外的帮助文本。 | -| primary_key | 将字段指定为模型的主键,未指定时会自动添加AutoField用于主键,只读。 | -| unique | 设置为True时,表中字段的值必须是唯一的 | -| verbose_name | 字段在后台模型管理显示的名称,未指定时使用字段的名称 | +| 选项 | 说明 | +| ---------------- | ------------------------------------------------------------ | +| `null` | 数据库中对应的字段是否允许为`NULL`,默认为`False` | +| `blank` | 后台模型管理验证数据时,是否允许为`NULL`,默认为`False` | +| `choices` | 设定字段的选项,各元组中的第一个值是设置在模型上的值,第二值是人类可读的值 | +| `db_column` | 字段对应到数据库表中的列名,未指定时直接使用字段的名称 | +| `db_index` | 设置为`True`时将在该字段创建索引 | +| `db_tablespace` | 为有索引的字段设置使用的表空间,默认为`DEFAULT_INDEX_TABLESPACE` | +| `default` | 字段的默认值 | +| `editable` | 字段在后台模型管理或`ModelForm`中是否显示,默认为`True` | +| `error_messages` | 设定字段抛出异常时的默认消息的字典,其中的键包括`null`、`blank`、`invalid`、`invalid_choice`、`unique`和`unique_for_date` | +| `help_text` | 表单小组件旁边显示的额外的帮助文本。 | +| `primary_key` | 将字段指定为模型的主键,未指定时会自动添加`AutoField`用于主键,只读。 | +| `unique` | 设置为`True`时,表中字段的值必须是唯一的 | +| `verbose_name` | 字段在后台模型管理显示的名称,未指定时使用字段的名称 | -ForeignKey属性 +`ForeignKey`属性 -1. limit_choices_to:值是一个Q对象或返回一个Q对象,用于限制后台显示哪些对象。 -2. related_name:用于获取关联对象的关联管理器对象(反向查询),如果不允许反向,该属性应该被设置为`'+'`,或者以`'+'`结尾。 -3. to_field:指定关联的字段,默认关联对象的主键字段。 -4. db_constraint:是否为外键创建约束,默认值为True。 -5. on_delete:外键关联的对象被删除时对应的动作,可取的值包括django.db.models中定义的: - - CASCADE:级联删除。 - - PROTECT:抛出ProtectedError异常,阻止删除引用的对象。 - - SET_NULL:把外键设置为null,当null属性被设置为True时才能这么做。 - - SET_DEFAULT:把外键设置为默认值,提供了默认值才能这么做。 +1. `limit_choices_to`:值是一个Q对象或返回一个Q对象,用于限制后台显示哪些对象。 +2. `related_name`:用于获取关联对象的关联管理器对象(反向查询),如果不允许反向,该属性应该被设置为`'+'`,或者以`'+'`结尾。 +3. `to_field`:指定关联的字段,默认关联对象的主键字段。 +4. `db_constraint`:是否为外键创建约束,默认值为`True`。 +5. `on_delete`:外键关联的对象被删除时对应的动作,可取的值包括`django.db.models`中定义的: + - `CASCADE`:级联删除。 + - `PROTECT`:抛出`ProtectedError`异常,阻止删除引用的对象。 + - `SET_NULL`:把外键设置为`null`,当`null`属性被设置为`True`时才能这么做。 + - `SET_DEFAULT`:把外键设置为默认值,提供了默认值才能这么做。 -ManyToManyField属性 +`ManyToManyField`属性 -1. symmetrical:是否建立对称的多对多关系。 -2. through:指定维持多对多关系的中间表的Django模型。 -3. throughfields:定义了中间模型时可以指定建立多对多关系的字段。 -4. db_table:指定维持多对多关系的中间表的表名。 +1. `symmetrical`:是否建立对称的多对多关系。 +2. `through`:指定维持多对多关系的中间表的Django模型。 +3. `throughfields`:定义了中间模型时可以指定建立多对多关系的字段。 +4. `db_table`:指定维持多对多关系的中间表的表名。 -#### 模型元数据选项 +##### 模型元数据选项 -| 选项 | 说明 | -| --------------------- | ------------------------------------------------------------ | -| abstract | 设置为True时模型是抽象父类 | -| app_label | 如果定义模型的应用不在INSTALLED_APPS中可以用该属性指定 | -| db_table | 模型使用的数据表名称 | -| db_tablespace | 模型使用的数据表空间 | -| default_related_name | 关联对象回指这个模型时默认使用的名称,默认为_set | -| get_latest_by | 模型中可排序字段的名称。 | -| managed | 设置为True时,Django在迁移中创建数据表并在执行flush管理命令时把表移除 | -| order_with_respect_to | 标记对象为可排序的 | -| ordering | 对象的默认排序 | -| permissions | 创建对象时写入权限表的额外权限 | -| default_permissions | 默认为`('add', 'change', 'delete')` | -| unique_together | 设定组合在一起时必须独一无二的字段名 | -| index_together | 设定一起建立索引的多个字段名 | -| verbose_name | 为对象设定人类可读的名称 | -| verbose_name_plural | 设定对象的复数名称 | +| 选项 | 说明 | +| ----------------------- | ------------------------------------------------------------ | +| `abstract` | 设置为True时模型是抽象父类 | +| `app_label` | 如果定义模型的应用不在INSTALLED_APPS中可以用该属性指定 | +| `db_table` | 模型使用的数据表名称 | +| `db_tablespace` | 模型使用的数据表空间 | +| `default_related_name` | 关联对象回指这个模型时默认使用的名称,默认为_set | +| `get_latest_by` | 模型中可排序字段的名称。 | +| `managed` | 设置为True时,Django在迁移中创建数据表并在执行flush管理命令时把表移除 | +| `order_with_respect_to` | 标记对象为可排序的 | +| `ordering` | 对象的默认排序 | +| `permissions` | 创建对象时写入权限表的额外权限 | +| `default_permissions` | 默认为`('add', 'change', 'delete')` | +| `unique_together` | 设定组合在一起时必须独一无二的字段名 | +| `index_together` | 设定一起建立索引的多个字段名 | +| `verbose_name` | 为对象设定人类可读的名称 | +| `verbose_name_plural` | 设定对象的复数名称 | -### 查询参考 +#### 查询参考 -按字段查找可以用的条件: +##### 按字段查找可以用的条件 -1. exact / iexact:精确匹配/忽略大小写的精确匹配查询 -2. contains / icontains / startswith / istartswith / endswith / iendswith:基于`like`的模糊查询 -3. in:集合运算 -4. gt / gte / lt / lte:大于/大于等于/小于/小于等于关系运算 -5. range:指定范围查询(SQL中的`between…and…`) -6. year / month / day / week_day / hour / minute / second:查询时间日期 -7. isnull:查询空值(True)或非空值(False) -8. search:基于全文索引的全文检索 -9. regex / iregex:基于正则表达式的模糊匹配查询 - -Q对象(用于执行复杂查询)的使用: - -```Shell ->>> from django.db.models import Q ->>> Emp.objects.filter( -... Q(name__startswith='张'), -... Q(sal__gte=5000) | Q(comm__gte=1000) -... ) # 查询名字以“张”开头且工资大于等于5000或补贴大于等于1000的员工 -]> -``` +1. `exact` / `iexact`:精确匹配/忽略大小写的精确匹配查询 +2. `contains` / `icontains` / `startswith` / `istartswith` / `endswith` / `iendswith`:基于`like`的模糊查询 +3. `in` :集合运算 +4. `gt` / `gte` / `lt` / `lte`:大于/大于等于/小于/小于等于关系运算 +5. `range`:指定范围查询(SQL中的`between…and…`) +6. `year` / `month` / `day` / `week_day` / `hour` / `minute` / `second`:查询时间日期 +7. `isnull`:查询空值(True)或非空值(False) +8. `search`:基于全文索引的全文检索(一般很少使用) +9. `regex` / `iregex`:基于正则表达式的模糊匹配查询 diff --git a/Day41-55/43.静态资源和Ajax请求.md b/Day41-55/43.静态资源和Ajax请求.md index 18f5df1..c6332a4 100644 --- a/Day41-55/43.静态资源和Ajax请求.md +++ b/Day41-55/43.静态资源和Ajax请求.md @@ -1,216 +1,60 @@ ## 静态资源和Ajax请求 -基于前面两个章节讲解的知识,我们已经可以使用Django框架来完成Web应用的开发了。接下来我们就尝试实现一个投票应用,具体的需求是用户进入应用首先查看到“学科介绍”页面,该页面显示了一个学校所开设的所有学科;通过点击某个学科,可以进入“老师介绍”页面,该页面展示了该学科所有老师的详细情况,可以在该页面上给老师点击“好评”或“差评”;如果用户没有登录,在投票时会先跳转到“登录页”要求用户登录,登录成功才能投票;对于未注册的用户,可以在“登录页”点击“新用户注册”进入“注册页”完成用户注册操作,注册成功后会跳转到“登录页”,注册失败会获得相应的提示信息。 - -### 准备工作 - -由于之前已经详细的讲解了如何创建Django项目以及项目的相关配置,因此我们略过这部分内容,唯一需要说明的是,从上面对投票应用需求的描述中我们可以分析出三个业务实体:学科、老师和用户。学科和老师之间通常是一对多关联关系(一个学科有多个老师,一个老师通常只属于一个学科),用户因为要给老师投票,所以跟老师之间是多对多关联关系(一个用户可以给多个老师投票,一个老师也可以收到多个用户的投票)。首先修改应用下的models.py文件来定义数据模型,先给出学科和老师的模型。 - -```Python -from django.db import models - - -class Subject(models.Model): - """学科""" - no = models.IntegerField(primary_key=True, verbose_name='编号') - name = models.CharField(max_length=20, verbose_name='名称') - intro = models.CharField(max_length=511, default='', verbose_name='介绍') - create_date = models.DateField(null=True, verbose_name='成立日期') - is_hot = models.BooleanField(default=False, verbose_name='是否热门') - - def __str__(self): - return self.name - - class Meta: - db_table = 'tb_subject' - verbose_name = '学科' - verbose_name_plural = '学科' - - -class Teacher(models.Model): - """老师""" - no = models.AutoField(primary_key=True, verbose_name='编号') - name = models.CharField(max_length=20, verbose_name='姓名') - detail = models.CharField(max_length=1023, default='', blank=True, verbose_name='详情') - photo = models.CharField(max_length=1023, default='', verbose_name='照片') - good_count = models.IntegerField(default=0, verbose_name='好评数') - bad_count = models.IntegerField(default=0, verbose_name='差评数') - subject = models.ForeignKey(to=Subject, on_delete=models.PROTECT, db_column='sno', verbose_name='所属学科') - - class Meta: - db_table = 'tb_teacher' - verbose_name = '老师' - verbose_name_plural = '老师' -``` - -模型定义完成后,可以通过“生成迁移”和“执行迁移”来完成关系型数据库中二维表的创建,当然这需要提前启动数据库服务器并创建好对应的数据库,同时我们在项目中已经安装了PyMySQL而且完成了相应的配置,这些内容此处不再赘述。 - -```Shell -(venv)$ python manage.py makemigrations vote -... -(venv)$ python manage.py migrate -... -``` - -> 注意:为了给vote应用生成迁移文件,需要修改Django项目settings.py文件,在INSTALLED_APPS中添加vote应用。 - -完成模型迁移之后,我们可以直接使用Django提供的后台管理来添加学科和老师信息,这需要先注册模型类和模型管理类。 - -```SQL -from django.contrib import admin - -from poll2.forms import UserForm -from poll2.models import Subject, Teacher - - -class SubjectAdmin(admin.ModelAdmin): - list_display = ('no', 'name', 'create_date', 'is_hot') - ordering = ('no', ) - - -class TeacherAdmin(admin.ModelAdmin): - list_display = ('no', 'name', 'detail', 'good_count', 'bad_count', 'subject') - ordering = ('subject', 'no') - - -admin.site.register(Subject, SubjectAdmin) -admin.site.register(Teacher, TeacherAdmin) -``` - -接下来,我们就可以修改views.py文件,通过编写视图函数先实现“学科介绍”页面。 - -```Python -def show_subjects(request): - """查看所有学科""" - subjects = Subject.objects.all() - return render(request, 'subject.html', {'subjects': subjects}) -``` - -至此,我们还需要一个模板页,模板的配置以及模板页中模板语言的用法在之前已经进行过简要的介绍,如果不熟悉可以看看下面的代码,相信这并不是一件困难的事情。 - -```HTML - - - - - 所有学科信息 - - - -

所有学科

-
- {% for subject in subjects %} -
-

- {{ subject.name }} - {% if subject.is_hot %} - - {% endif %} -

-

{{ subject.intro }}

-
- {% endfor %} - - -``` - -在上面的模板中,我们为每个学科添加了一个超链接,点击超链接可以查看该学科的讲师信息,为此需要再编写一个视图函数来处理查看指定学科老师信息。 - -```Python -def show_teachers(request): - """显示指定学科的老师""" - try: - sno = int(request.GET['sno']) - subject = Subject.objects.get(no=sno) - teachers = subject.teacher_set.all() - return render(request, 'teachers.html', {'subject': subject, 'teachers': teachers}) - except (KeyError, ValueError, Subject.DoesNotExist): - return redirect('/') -``` - -显示老师信息的模板页。 - -```HTML - -{% load static %} - - - - 老师 - - - -

{{ subject.name }}学科老师信息

-
- {% if teachers %} - {% for teacher in teachers %} -
-
- -
-
-

{{ teacher.name }}

-

{{ teacher.detail }}

-

- 好评 - ({{ teacher.good_count }}) - 差评 - ({{ teacher.bad_count }}) -

-
-
- {% endfor %} - {% else %} -

暂时没有该学科的老师信息

- {% endif %} -

- 返回首页 -

- - -``` - ### 加载静态资源 -在上面的模板页面中,我们使用了``标签来加载老师的照片,其中使用了引用静态资源的模板指令`{% static %}`,要使用该指令,首先要使用`{% load static %}`指令来加载静态资源,我们将这段代码放在了页码开始的位置。在上面的项目中,我们将静态资源置于名为static的文件夹中,在该文件夹下又创建了三个文件夹:css、js和images,分别用来保存外部层叠样式表、外部JavaScript文件和图片资源。为了能够找到保存静态资源的文件夹,我们还需要修改Django项目的配置文件settings.py,如下所示: +如果要在Django项目中使用静态资源,可以先创建一个用于保存静态资源的目录。在`vote`项目中,我们将静态资源置于名为`static`的文件夹中,在该文件夹包含了三个子文件夹:css、js和images,分别用来保存外部CSS文件、外部JavaScript文件和图片资源,如下图所示。 + +![](res/pycharm-django-static.png) + +为了能够找到保存静态资源的文件夹,我们还需要修改Django项目的配置文件`settings.py`,如下所示: ```Python -# 此处省略上面的代码 - STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ] STATIC_URL = '/static/' - -# 此处省略下面的代码 ``` -接下来修改urls.py文件,配置用户请求的URL和视图函数的对应关系。 +配置好静态资源之后,大家可以运行项目,然后看看之前我们写的页面上的图片是否能够正常加载出来。需要说明的是,在项目正式部署到线上环境后,我们通常会把静态资源交给专门的静态资源服务器(如Nginx、Apache)来处理,而不是有运行Python代码的服务器来管理静态资源,所以上面的配置并不适用于生产环境,仅供项目开发阶段测试使用。使用静态资源的正确姿势我们会在后续的章节为大家讲解。 -```Python -from django.contrib import admin -from django.urls import path +### Ajax概述 -from vote import views +接下来就可以实现“好评”和“差评”的功能了,很明显如果能够在不刷新页面的情况下实现这两个功能会带来更好的用户体验,因此我们考虑使用[Ajax](https://zh.wikipedia.org/wiki/AJAX)技术来实现“好评”和“差评”。Ajax是Asynchronous Javascript And XML的缩写 , 简单的说,使用Ajax技术可以在不重新加载整个页面的情况下对页面进行局部刷新。 -urlpatterns = [ - path('', views.show_subjects), - path('teachers/', views.show_teachers), - path('admin/', admin.site.urls), -] +对于传统的Web应用,每次页面上需要加载新的内容都需要重新请求服务器并刷新整个页面,如果服务器短时间内无法给予响应或者网络状况并不理想,那么可能会造成浏览器长时间的空白并使得用户处于等待状态,在这个期间用户什么都做不了,如下图所示。很显然,这样的Web应用并不能带来很好的用户体验。 + +![](res/synchronous-web-request.png) + +对于使用Ajax技术的Web应用,浏览器可以向服务器发起异步请求来获取数据。异步请求不会中断用户体验,当服务器返回了新的数据,我们可以通过JavaScript代码进行DOM操作来实现对页面的局部刷新,这样就相当于在不刷新整个页面的情况下更新了页面的内容,如下图所示。 + +![](res/asynchronous-web-request.png) + +在使用Ajax技术时,浏览器跟服务器通常会交换XML或JSON格式的数据,XML是以前使用得非常多的一种数据格式,近年来几乎已经完全被JSON取代,下面是两种数据格式的对比。 + +XML格式: + +```XML + + + Alice + Bob + Dinner is on me! + ``` -启动服务器运行项目,进入首页查看学科信息。 +JSON格式: -![](./res/show_subjects.png) +```JSON +{ + "from": "Alice", + "to": "Bob", + "content": "Dinner is on me!" +} +``` -点击学科查看老师信息。 +通过上面的对比,明显JSON格式的数据要紧凑得多,所以传输效率更高,而且JSON本身也是JavaScript中的一种对象表达式语法,在JavaScript代码中处理JSON格式的数据更加方便。 -![](./res/show_teachers.png) +### 用Ajax实现投票功能 -### Ajax请求 - -接下来就可以实现“好评”和“差评”的功能了,很明显如果能够在不刷新页面的情况下实现这两个功能会带来更好的用户体验,因此我们考虑使用[Ajax](https://zh.wikipedia.org/wiki/AJAX)技术来实现“好评”和“差评”,Ajax技术我们在Web前端部分已经介绍过了,此处不再赘述。 - -首先修改项目的urls.py文件,为“好评”和“差评”功能映射对应的URL。 +下面,我们使用Ajax技术来实现投票的功能,首先修改项目的`urls.py`文件,为“好评”和“差评”功能映射对应的URL。 ```Python from django.contrib import admin @@ -233,16 +77,18 @@ urlpatterns = [ def praise_or_criticize(request): """好评""" try: - tno = int(request.GET['tno']) + tno = int(request.GET.get('tno')) teacher = Teacher.objects.get(no=tno) if request.path.startswith('/praise'): teacher.good_count += 1 + count = teacher.good_count else: teacher.bad_count += 1 + count = teacher.bad_count teacher.save() - data = {'code': 200, 'hint': '操作成功'} - except (KeyError, ValueError, Teacher.DoseNotExist): - data = {'code': 404, 'hint': '操作失败'} + data = {'code': 20000, 'mesg': '操作成功', 'count': count} + except (ValueError, Teacher.DoseNotExist): + data = {'code': 20001, 'mesg': '操作失败'} return JsonResponse(data) ``` @@ -250,54 +96,90 @@ def praise_or_criticize(request): ```HTML -{% load static %} - 老师 - + 老师信息 + -

{{ subject.name }}学科老师信息

-
- {% if teachers %} - {% for teacher in teachers %} -
-
- +
+

{{ subject.name }}学科的老师信息

+
+ {% if not teachers %} +

暂无该学科老师信息

+ {% endif %} + {% for teacher in teachers %} +
+
+ +
+
+
+ 姓名:{{ teacher.name }} + 性别:{{ teacher.sex | yesno:'男,女' }} + 出生日期:{{ teacher.birth }} +
+
{{ teacher.intro }}
+
+ 好评   + ({{ teacher.good_count }}) +      + 差评   + ({{ teacher.bad_count }}) +
+
-
-

{{ teacher.name }}

-

{{ teacher.detail }}

-

- 好评 - ({{ teacher.good_count }}) -    - 差评 - ({{ teacher.bad_count }}) -

-
-
- {% endfor %} - {% else %} -

暂时没有该学科的老师信息

- {% endif %} -

+ {% endfor %} 返回首页 -

+
+ + + +``` + +运行效果如下图所示。 + +![](./res/echarts_bar_graph.png) diff --git a/Day41-55/46.报表和日志.md b/Day41-55/46.报表和日志.md deleted file mode 100644 index dffdcfc..0000000 --- a/Day41-55/46.报表和日志.md +++ /dev/null @@ -1,351 +0,0 @@ -## 报表和日志 - -### 导出Excel报表 - -报表就是用表格、图表等格式来动态显示数据,所以有人用这样的公式来描述报表: - -``` -报表 = 多样的格式 + 动态的数据 -``` - -有很多的三方库支持在Python程序中写Excel文件,包括[xlwt]()、[xlwings]()、[openpyxl]()、[xlswriter]()、[pandas]()等,其中的xlwt虽然只支持写xls格式的Excel文件,但在性能方面的表现还是不错的。下面我们就以xlwt为例,来演示如何在Django项目中导出Excel报表,例如导出一个包含所有老师信息的Excel表格。 - -```Python -def export_teachers_excel(request): - # 创建工作簿 - wb = xlwt.Workbook() - # 添加工作表 - sheet = wb.add_sheet('老师信息表') - # 查询所有老师的信息(注意:这个地方稍后需要优化) - queryset = Teacher.objects.all() - # 向Excel表单中写入表头 - colnames = ('姓名', '介绍', '好评数', '差评数', '学科') - for index, name in enumerate(colnames): - sheet.write(0, index, name) - # 向单元格中写入老师的数据 - props = ('name', 'detail', 'good_count', 'bad_count', 'subject') - for row, teacher in enumerate(queryset): - for col, prop in enumerate(props): - value = getattr(teacher, prop, '') - if isinstance(value, Subject): - value = value.name - sheet.write(row + 1, col, value) - # 保存Excel - buffer = BytesIO() - wb.save(buffer) - # 将二进制数据写入响应的消息体中并设置MIME类型 - resp = HttpResponse(buffer.getvalue(), content_type='application/vnd.ms-excel') - # 中文文件名需要处理成百分号编码 - filename = quote('老师.xls') - # 通过响应头告知浏览器下载该文件以及对应的文件名 - resp['content-disposition'] = f'attachment; filename="{filename}"' - return resp -``` - -映射URL。 - -```Python -urlpatterns = [ - # 此处省略上面的代码 - path('excel/', views.export_teachers_excel), - # 此处省略下面的代码 -] -``` - -### 生成前端统计图表 - -如果项目中需要生成前端统计图表,可以使用百度的[ECharts]()。具体的做法是后端通过提供数据接口返回统计图表所需的数据,前端使用ECharts来渲染出柱状图、折线图、饼图、散点图等图表。例如我们要生成一个统计所有老师好评数和差评数的报表,可以按照下面的方式来做。 - -```Python -def get_teachers_data(request): - # 查询所有老师的信息(注意:这个地方稍后也需要优化) - queryset = Teacher.objects.all() - # 用生成式将老师的名字放在一个列表中 - names = [teacher.name for teacher in queryset] - # 用生成式将老师的好评数放在一个列表中 - good = [teacher.good_count for teacher in queryset] - # 用生成式将老师的差评数放在一个列表中 - bad = [teacher.bad_count for teacher in queryset] - # 返回JSON格式的数据 - return JsonResponse({'names': names, 'good': good, 'bad': bad}) -``` - -映射URL。 - -```Python -urlpatterns = [ - # 此处省略上面的代码 - path('teachers_data/', views.export_teachers_excel), - # 此处省略下面的代码 -] -``` - -使用ECharts生成柱状图。 - -```HTML - - - - - 老师评价统计 - - -
-

- 返回首页 -

- - - - -``` - -运行效果如下图所示。 - -![](./res/echarts_bar_graph.png) - -### 配置日志 - -项目开发阶段,显示足够的调试信息以辅助开发人员调试代码还是非常必要的;项目上线以后,将系统运行时出现的警告、错误等信息记录下来以备相关人员了解系统运行状况并维护代码也是很有必要的。要做好这两件事件,我们需要为Django项目配置日志。 - -Django的日志配置基本可以参照官方文档再结合项目实际需求来进行,这些内容基本上可以从官方文档上复制下来,然后进行局部的调整即可,下面给出一些参考配置。 - -```Python -LOGGING = { - 'version': 1, - # 是否禁用已经存在的日志器 - 'disable_existing_loggers': False, - # 日志格式化器 - 'formatters': { - 'simple': { - 'format': '%(asctime)s %(module)s.%(funcName)s: %(message)s', - 'datefmt': '%Y-%m-%d %H:%M:%S', - }, - 'verbose': { - 'format': '%(asctime)s %(levelname)s [%(process)d-%(threadName)s] ' - '%(module)s.%(funcName)s line %(lineno)d: %(message)s', - 'datefmt': '%Y-%m-%d %H:%M:%S', - } - }, - # 日志过滤器 - 'filters': { - # 只有在Django配置文件中DEBUG值为True时才起作用 - 'require_debug_true': { - '()': 'django.utils.log.RequireDebugTrue', - }, - }, - # 日志处理器 - 'handlers': { - # 输出到控制台 - 'console': { - 'class': 'logging.StreamHandler', - 'level': 'DEBUG', - 'filters': ['require_debug_true'], - 'formatter': 'simple', - }, - # 输出到文件(每周切割一次) - 'file1': { - 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': 'access.log', - 'when': 'W0', - 'backupCount': 12, - 'formatter': 'simple', - 'level': 'INFO', - }, - # 输出到文件(每天切割一次) - 'file2': { - 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': 'error.log', - 'when': 'D', - 'backupCount': 31, - 'formatter': 'verbose', - 'level': 'WARNING', - }, - }, - # 日志器记录器 - 'loggers': { - 'django': { - # 需要使用的日志处理器 - 'handlers': ['console', 'file1', 'file2'], - # 是否向上传播日志信息 - 'propagate': True, - # 日志级别(不一定是最终的日志级别) - 'level': 'DEBUG', - }, - } -} -``` - -大家可能已经注意到了,上面日志配置中的formatters是**日志格式化器**,它代表了如何格式化输出日志,其中格式占位符分别表示: - -1. %(name)s - 记录器的名称 -2. %(levelno)s - 数字形式的日志记录级别 -3. %(levelname)s - 日志记录级别的文本名称 -4. %(filename)s - 执行日志记录调用的源文件的文件名称 -5. %(pathname)s - 执行日志记录调用的源文件的路径名称 -6. %(funcName)s - 执行日志记录调用的函数名称 -7. %(module)s - 执行日志记录调用的模块名称 -8. %(lineno)s - 执行日志记录调用的行号 -9. %(created)s - 执行日志记录的时间 -10. %(asctime)s - 日期和时间 -11. %(msecs)s - 毫秒部分 -12. %(thread)d - 线程ID(整数) -13. %(threadName)s - 线程名称 -14. %(process)d - 进程ID (整数) - -日志配置中的handlers用来指定**日志处理器**,简单的说就是指定将日志输出到控制台还是文件又或者是网络上的服务器,可用的处理器包括: - -1. logging.StreamHandler(stream=None) - 可以向类似与sys.stdout或者sys.stderr的任何文件对象输出信息 -2. logging.FileHandler(filename, mode='a', encoding=None, delay=False) - 将日志消息写入文件 -3. logging.handlers.DatagramHandler(host, port) - 使用UDP协议,将日志信息发送到指定主机和端口的网络主机上 -4. logging.handlers.HTTPHandler(host, url) - 使用HTTP的GET或POST方法将日志消息上传到一台HTTP 服务器 -5. logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False) - 将日志消息写入文件,如果文件的大小超出maxBytes指定的值,那么将重新生成一个文件来记录日志 -6. logging.handlers.SocketHandler(host, port) - 使用TCP协议,将日志信息发送到指定主机和端口的网络主机上 -7. logging.handlers.SMTPHandler(mailhost, fromaddr, toaddrs, subject, credentials=None, secure=None, timeout=1.0) - 将日志输出到指定的邮件地址 -8. logging.MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True) - 将日志输出到内存指定的缓冲区中 - -上面每个日志处理器都指定了一个名为“level”的属性,它代表了日志的级别,不同的日志级别反映出日志中记录信息的严重性。Python中定义了六个级别的日志,按照从低到高的顺序依次是:NOTSET、DEBUG、INFO、WARNING、ERROR、CRITICAL。 - -最后配置的**日志记录器**是用来真正输出日志的,Django框架提供了如下所示的内置记录器: - -1. django - 在Django层次结构中的所有消息记录器 -2. django.request - 与请求处理相关的日志消息。5xx响应被视为错误消息;4xx响应被视为为警告消息 -3. django.server - 与通过runserver调用的服务器所接收的请求相关的日志消息。5xx响应被视为错误消息;4xx响应被记录为警告消息;其他一切都被记录为INFO -4. django.template - 与模板渲染相关的日志消息 -5. django.db.backends - 有与数据库交互产生的日志消息,如果希望显示ORM框架执行的SQL语句,就可以使用该日志记录器。 - -日志记录器中配置的日志级别有可能不是最终的日志级别,因为还要参考日志处理器中配置的日志级别,取二者中级别较高者作为最终的日志级别。 - -### 配置Django-Debug-Toolbar - -Django-Debug-Toolbar是项目开发阶段辅助调试和优化的神器,只要配置了它,就可以很方便的查看到如下表所示的项目运行信息,这些信息对调试项目和优化Web应用性能都是至关重要的。 - -| 项目 | 说明 | -| ----------- | --------------------------------- | -| Versions | Django的版本 | -| Time | 显示视图耗费的时间 | -| Settings | 配置文件中设置的值 | -| Headers | HTTP请求头和响应头的信息 | -| Request | 和请求相关的各种变量及其信息 | -| StaticFiles | 静态文件加载情况 | -| Templates | 模板的相关信息 | -| Cache | 缓存的使用情况 | -| Signals | Django内置的信号信息 | -| Logging | 被记录的日志信息 | -| SQL | 向数据库发送的SQL语句及其执行时间 | - -1. 安装Django-Debug-Toolbar。 - - ```Shell - pip install django-debug-toolbar - ``` - -2. 配置 - 修改settings.py。 - - ```Python - INSTALLED_APPS = [ - 'debug_toolbar', - ] - - MIDDLEWARE = [ - 'debug_toolbar.middleware.DebugToolbarMiddleware', - ] - - DEBUG_TOOLBAR_CONFIG = { - # 引入jQuery库 - 'JQUERY_URL': 'https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js', - # 工具栏是否折叠 - 'SHOW_COLLAPSED': True, - # 是否显示工具栏 - 'SHOW_TOOLBAR_CALLBACK': lambda x: True, - } - ``` - -3. 配置 - 修改urls.py。 - - ```Python - if settings.DEBUG: - - import debug_toolbar - - urlpatterns.insert(0, path('__debug__/', include(debug_toolbar.urls))) - ``` - -4. 使用 - 如下图所示,在配置好Django-Debug-Toolbar之后,页面右侧会看到一个调试工具栏,上面包括了如前所述的各种调试信息,包括执行时间、项目设置、请求头、SQL、静态资源、模板、缓存、信号等,查看起来非常的方便。 - -### 优化ORM代码 - -在配置了日志或Django-Debug-Toolbar之后,我们可以查看一下之前将老师数据导出成Excel报表的视图函数执行情况,这里我们关注的是ORM框架生成的SQL查询到底是什么样子的,相信这里的结果会让你感到有一些意外。执行`Teacher.objects.all()`之后我们可以注意到,在控制台看到的或者通过Django-Debug-Toolbar输出的SQL是下面这样的: - -```SQL -SELECT `tb_teacher`.`no`, `tb_teacher`.`name`, `tb_teacher`.`detail`, `tb_teacher`.`photo`, `tb_teacher`.`good_count`, `tb_teacher`.`bad_count`, `tb_teacher`.`sno` FROM `tb_teacher`; args=() -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 103; args=(103,) -SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 103; args=(103,) -``` - -这里的问题通常被称为“1+N查询”(或“N+1查询”),原本获取老师的数据只需要一条SQL,但是由于老师关联了学科,当我们查询到N条老师的数据时,Django的ORM框架又向数据库发出了N条SQL去查询老师所属学科的信息。每条SQL执行都会有较大的开销而且会给数据库服务器带来压力,如果能够在一条SQL中完成老师和学科的查询肯定是更好的做法,这一点也很容易做到,相信大家已经想到怎么做了。是的,我们可以使用连接查询,但是在使用Django的ORM框架时如何做到这一点呢?对于多对一关联(如投票应用中的老师和学科),我们可以使用`QuerySet`的用`select_related()`方法来加载关联对象;而对于多对多关联(如电商网站中的订单和商品),我们可以使用`prefetch_related()`方法来加载关联对象。 - -在导出老师Excel报表的视图函数中,我们可以按照下面的方式优化代码。 - -```Python -queryset = Teacher.objects.all().select_related('subject') -``` - -事实上,用ECharts生成前端报表的视图函数中,查询老师好评和差评数据的操作也能够优化,因为在这个例子中,我们只需要获取老师的姓名、好评数和差评数这三项数据,但是在默认的情况生成的SQL会查询老师表的所有字段。可以用`QuerySet`的`only()`方法来指定需要查询的属性,也可以用`QuerySet`的`defer()`方法来指定暂时不需要查询的属性,这样生成的SQL会通过投影操作来指定需要查询的列,从而改善查询性能,代码如下所示: - -```Python -queryset = Teacher.objects.all().only('name', 'good_count', 'bad_count') -``` - -当然,如果要统计出每个学科的老师好评和差评的平均数,利用Django的ORM框架也能够做到,代码如下所示: - -```Python -queryset = Teacher.objects.values('subject').annotate( - good=Avg('good_count'), bad=Avg('bad_count')) -``` - -这里获得的`QuerySet`中的元素是字典对象,每个字典中有三组键值对,分别是代表学科编号的`subject`、代表好评数的`good`和代表差评数的`bad`。如果想要获得学科的名称而不是编号,可以按照如下所示的方式调整代码: - -```Python -queryset = Teacher.objects.values('subject__name').annotate( - good=Avg('good_count'), bad=Avg('bad_count')) -``` - -可见,Django的ORM框架允许我们用面向对象的方式完成关系数据库中的分组和聚合查询。 \ No newline at end of file diff --git a/Day41-55/46.日志和调试工具栏.md b/Day41-55/46.日志和调试工具栏.md new file mode 100644 index 0000000..a880881 --- /dev/null +++ b/Day41-55/46.日志和调试工具栏.md @@ -0,0 +1,215 @@ +## 日志和调试工具栏 + +### 配置日志 + +项目开发阶段,显示足够的调试信息以辅助开发人员调试代码还是非常必要的;项目上线以后,将系统运行时出现的警告、错误等信息记录下来以备相关人员了解系统运行状况并维护代码也是很有必要的。与此同时,采集日志数据也是为网站做数字化运营奠定一个基础,通过对系统运行日志的分析,我们可以监测网站的流量以及流量分布,同时还可以挖掘出用户的使用习惯和行为模式。 + +接下来,我们先看看如何通过Django的配置文件来配置日志。Django的日志配置基本可以参照官方文档再结合项目实际需求来进行,这些内容基本上可以从官方文档上复制下来,然后进行局部的调整即可,下面给出一些参考配置。 + +```Python +LOGGING = { + 'version': 1, + # 是否禁用已经存在的日志器 + 'disable_existing_loggers': False, + # 日志格式化器 + 'formatters': { + 'simple': { + 'format': '%(asctime)s %(module)s.%(funcName)s: %(message)s', + 'datefmt': '%Y-%m-%d %H:%M:%S', + }, + 'verbose': { + 'format': '%(asctime)s %(levelname)s [%(process)d-%(threadName)s] ' + '%(module)s.%(funcName)s line %(lineno)d: %(message)s', + 'datefmt': '%Y-%m-%d %H:%M:%S', + } + }, + # 日志过滤器 + 'filters': { + # 只有在Django配置文件中DEBUG值为True时才起作用 + 'require_debug_true': { + '()': 'django.utils.log.RequireDebugTrue', + }, + }, + # 日志处理器 + 'handlers': { + # 输出到控制台 + 'console': { + 'class': 'logging.StreamHandler', + 'level': 'DEBUG', + 'filters': ['require_debug_true'], + 'formatter': 'simple', + }, + # 输出到文件(每周切割一次) + 'file1': { + 'class': 'logging.handlers.TimedRotatingFileHandler', + 'filename': 'access.log', + 'when': 'W0', + 'backupCount': 12, + 'formatter': 'simple', + 'level': 'INFO', + }, + # 输出到文件(每天切割一次) + 'file2': { + 'class': 'logging.handlers.TimedRotatingFileHandler', + 'filename': 'error.log', + 'when': 'D', + 'backupCount': 31, + 'formatter': 'verbose', + 'level': 'WARNING', + }, + }, + # 日志器记录器 + 'loggers': { + 'django': { + # 需要使用的日志处理器 + 'handlers': ['console', 'file1', 'file2'], + # 是否向上传播日志信息 + 'propagate': True, + # 日志级别(不一定是最终的日志级别) + 'level': 'DEBUG', + }, + } +} +``` + +大家可能已经注意到了,上面日志配置中的`formatters`是**日志格式化器**,它代表了如何格式化输出日志,其中格式占位符分别表示: + +1. `%(name)s` - 记录器的名称 +2. `%(levelno)s` - 数字形式的日志记录级别 +3. `%(levelname)s` - 日志记录级别的文本名称 +4. `%(filename)s` - 执行日志记录调用的源文件的文件名称 +5. `%(pathname)s` - 执行日志记录调用的源文件的路径名称 +6. `%(funcName)s` - 执行日志记录调用的函数名称 +7. `%(module)s` - 执行日志记录调用的模块名称 +8. `%(lineno)s` - 执行日志记录调用的行号 +9. `%(created)s` - 执行日志记录的时间 +10. `%(asctime)s` - 日期和时间 +11. `%(msecs)s` - 毫秒部分 +12. `%(thread)d` - 线程ID(整数) +13. `%(threadName)s` - 线程名称 +14. `%(process)d` - 进程ID (整数) + +日志配置中的handlers用来指定**日志处理器**,简单的说就是指定将日志输出到控制台还是文件又或者是网络上的服务器,可用的处理器包括: + +1. `logging.StreamHandler(stream=None)` - 可以向类似与`sys.stdout`或者`sys.stderr`的任何文件对象输出信息 +2. `logging.FileHandler(filename, mode='a', encoding=None, delay=False)` - 将日志消息写入文件 +3. `logging.handlers.DatagramHandler(host, port)` - 使用UDP协议,将日志信息发送到指定主机和端口的网络主机上 +4. `logging.handlers.HTTPHandler(host, url)` - 使用HTTP的GET或POST方法将日志消息上传到一台HTTP 服务器 +5. `logging.handlers.RotatingFileHandler(filename, mode='a', maxBytes=0, backupCount=0, encoding=None, delay=False)` - 将日志消息写入文件,如果文件的大小超出`maxBytes`指定的值,那么将重新生成一个文件来记录日志 +6. `logging.handlers.SocketHandler(host, port)` - 使用TCP协议,将日志信息发送到指定主机和端口的网络主机上 +7. `logging.handlers.SMTPHandler(mailhost, fromaddr, toaddrs, subject, credentials=None, secure=None, timeout=1.0)` - 将日志输出到指定的邮件地址 +8. `logging.MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True)` - 将日志输出到内存指定的缓冲区中 + +上面每个日志处理器都指定了一个名为`level`的属性,它代表了日志的级别,不同的日志级别反映出日志中记录信息的严重性。Python中定义了六个级别的日志,按照从低到高的顺序依次是:NOTSET、DEBUG、INFO、WARNING、ERROR、CRITICAL。 + +最后配置的**日志记录器**是用来真正输出日志的,Django框架提供了如下所示的内置记录器: + +1. `django` - 在Django层次结构中的所有消息记录器 +2. `django.request` - 与请求处理相关的日志消息。5xx响应被视为错误消息;4xx响应被视为为警告消息 +3. `django.server` - 与通过runserver调用的服务器所接收的请求相关的日志消息。5xx响应被视为错误消息;4xx响应被记录为警告消息;其他一切都被记录为INFO +4. `django.template` - 与模板渲染相关的日志消息 +5. `django.db.backends` - 有与数据库交互产生的日志消息,如果希望显示ORM框架执行的SQL语句,就可以使用该日志记录器。 + +日志记录器中配置的日志级别有可能不是最终的日志级别,因为还要参考日志处理器中配置的日志级别,取二者中级别较高者作为最终的日志级别。 + +### 配置Django-Debug-Toolbar + +如果想调试你的Django项目,你一定不能不过名为Django-Debug-Toolbar的神器,它是项目开发阶段辅助调试和优化的必备工具,只要配置了它,就可以很方便的查看到如下表所示的项目运行信息,这些信息对调试项目和优化Web应用性能都是至关重要的。 + +| 项目 | 说明 | +| ----------- | --------------------------------- | +| Versions | Django的版本 | +| Time | 显示视图耗费的时间 | +| Settings | 配置文件中设置的值 | +| Headers | HTTP请求头和响应头的信息 | +| Request | 和请求相关的各种变量及其信息 | +| StaticFiles | 静态文件加载情况 | +| Templates | 模板的相关信息 | +| Cache | 缓存的使用情况 | +| Signals | Django内置的信号信息 | +| Logging | 被记录的日志信息 | +| SQL | 向数据库发送的SQL语句及其执行时间 | + +1. 安装Django-Debug-Toolbar。 + + ```Shell + pip install django-debug-toolbar + ``` + +2. 配置 - 修改settings.py。 + + ```Python + INSTALLED_APPS = [ + 'debug_toolbar', + ] + + MIDDLEWARE = [ + 'debug_toolbar.middleware.DebugToolbarMiddleware', + ] + + DEBUG_TOOLBAR_CONFIG = { + # 引入jQuery库 + 'JQUERY_URL': 'https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js', + # 工具栏是否折叠 + 'SHOW_COLLAPSED': True, + # 是否显示工具栏 + 'SHOW_TOOLBAR_CALLBACK': lambda x: True, + } + ``` + +3. 配置 - 修改urls.py。 + + ```Python + if settings.DEBUG: + + import debug_toolbar + + urlpatterns.insert(0, path('__debug__/', include(debug_toolbar.urls))) + ``` + +4. 在配置好Django-Debug-Toolbar之后,页面右侧会看到一个调试工具栏,如下图所示,上面包括了如前所述的各种调试信息,包括执行时间、项目设置、请求头、SQL、静态资源、模板、缓存、信号等,查看起来非常的方便。 + + ![](res/debug-toolbar.png) + +### 优化ORM代码 + +在配置了日志或Django-Debug-Toolbar之后,我们可以查看一下之前将老师数据导出成Excel报表的视图函数执行情况,这里我们关注的是ORM框架生成的SQL查询到底是什么样子的,相信这里的结果会让你感到有一些意外。执行`Teacher.objects.all()`之后我们可以注意到,在控制台看到的或者通过Django-Debug-Toolbar输出的SQL是下面这样的: + +```SQL +SELECT `tb_teacher`.`no`, `tb_teacher`.`name`, `tb_teacher`.`detail`, `tb_teacher`.`photo`, `tb_teacher`.`good_count`, `tb_teacher`.`bad_count`, `tb_teacher`.`sno` FROM `tb_teacher`; args=() +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 101; args=(101,) +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 103; args=(103,) +SELECT `tb_subject`.`no`, `tb_subject`.`name`, `tb_subject`.`intro`, `tb_subject`.`create_date`, `tb_subject`.`is_hot` FROM `tb_subject` WHERE `tb_subject`.`no` = 103; args=(103,) +``` + +这里的问题通常被称为“1+N查询”(有的地方也将其称之为“N+1查询”),原本获取老师的数据只需要一条SQL,但是由于老师关联了学科,当我们查询到`N`条老师的数据时,Django的ORM框架又向数据库发出了`N`条SQL去查询老师所属学科的信息。每条SQL执行都会有较大的开销而且会给数据库服务器带来压力,如果能够在一条SQL中完成老师和学科的查询肯定是更好的做法,这一点也很容易做到,相信大家已经想到怎么做了。是的,我们可以使用连接查询,但是在使用Django的ORM框架时如何做到这一点呢?对于多对一关联(如投票应用中的老师和学科),我们可以使用`QuerySet`的用`select_related()`方法来加载关联对象;而对于多对多关联(如电商网站中的订单和商品),我们可以使用`prefetch_related()`方法来加载关联对象。 + +在导出老师Excel报表的视图函数中,我们可以按照下面的方式优化代码。 + +```Python +queryset = Teacher.objects.all().select_related('subject') +``` + +事实上,用ECharts生成前端报表的视图函数中,查询老师好评和差评数据的操作也能够优化,因为在这个例子中,我们只需要获取老师的姓名、好评数和差评数这三项数据,但是在默认的情况生成的SQL会查询老师表的所有字段。可以用`QuerySet`的`only()`方法来指定需要查询的属性,也可以用`QuerySet`的`defer()`方法来指定暂时不需要查询的属性,这样生成的SQL会通过投影操作来指定需要查询的列,从而改善查询性能,代码如下所示: + +```Python +queryset = Teacher.objects.all().only('name', 'good_count', 'bad_count') +``` + +当然,如果要统计出每个学科的老师好评和差评的平均数,利用Django的ORM框架也能够做到,代码如下所示: + +```Python +queryset = Teacher.objects.values('subject').annotate(good=Avg('good_count'), bad=Avg('bad_count')) +``` + +这里获得的`QuerySet`中的元素是字典对象,每个字典中有三组键值对,分别是代表学科编号的`subject`、代表好评数的`good`和代表差评数的`bad`。如果想要获得学科的名称而不是编号,可以按照如下所示的方式调整代码: + +```Python +queryset = Teacher.objects.values('subject__name').annotate(good=Avg('good_count'), bad=Avg('bad_count')) +``` + +可见,Django的ORM框架允许我们用面向对象的方式完成关系数据库中的分组和聚合查询。 + diff --git a/Day41-55/47.中间件的应用.md b/Day41-55/47.中间件的应用.md index 4eecd40..1a670d0 100644 --- a/Day41-55/47.中间件的应用.md +++ b/Day41-55/47.中间件的应用.md @@ -1,55 +1,6 @@ ## 中间件的应用 -### 实现登录验证 - -我们继续来完善投票应用。在上一个章节中,我们在用户登录成功后通过session保留了用户信息,接下来我们可以应用做一些调整,要求在为老师投票时必须要先登录,登录过的用户可以投票,否则就将用户引导到登录页面,为此我们可以这样修改视图函数。 - -```Python -def praise_or_criticize(request: HttpRequest): - """投票""" - if 'username' in request.session: - try: - tno = int(request.GET.get('tno', '0')) - teacher = Teacher.objects.get(no=tno) - if request.path.startswith('/praise'): - teacher.good_count += 1 - else: - teacher.bad_count += 1 - teacher.save() - data = {'code': 200, 'message': '操作成功'} - except (ValueError, Teacher.DoesNotExist): - data = {'code': 404, 'message': '操作失败'} - else: - data = {'code': 401, 'message': '请先登录'} - return JsonResponse(data) -``` - -前端页面在收到`{'code': 401, 'message': '请先登录'}`后,可以将用户引导到登录页面,修改后的teacher.html页面的JavaScript代码部门如下所示。 - -```HTML - -``` - -> 注意:为了在登录成功之后能够回到刚才投票的页面,我们在跳转登录时设置了一个`backurl`参数,把当前浏览器中的URL作为返回的页面地址。 - -这样我们已经实现了用户必须登录才能投票的限制,但是一个新的问题来了。如果我们的应用中有很多功能都需要用户先登录才能执行,例如将前面导出Excel报表和查看统计图表的功能都加以登录限制,那么我们是不是需要在每个视图函数中添加代码来检查session中是否包含了登录用户的信息呢?答案是否定的,如果这样做了,我们的视图函数中必然会充斥着大量的重复代码。编程大师*Martin Fowler*曾经说过:**代码有很多种坏味道,重复是最坏的一种**。在Django项目中,我们可以把验证用户是否登录这样的重复性代码放到中间件中。 +之前我们已经实现了用户必须登录才能投票的限制,但是一个新的问题来了。如果我们的应用中有很多功能都需要用户先登录才能执行,例如将前面导出Excel报表和查看统计图表的功能都做了必须登录才能访问的限制,那么我们是不是需要在每个视图函数中添加代码来检查session中是否包含`userid`的代码呢?答案是否定的,如果这样做了,我们的视图函数中必然会充斥着大量的重复代码。编程大师*Martin Fowler*曾经说过:**代码有很多种坏味道,重复是最坏的一种**。在Python程序中,我们可以通过装饰器来为函数提供额外的能力;在Django项目中,我们可以把类似于验证用户是否登录这样的重复性代码放到**中间件**中。 ### Django中间件概述 @@ -71,20 +22,20 @@ MIDDLEWARE = [ 我们稍微为大家解释一下这些中间件的作用: -1. CommonMiddleware - 基础设置中间件,可以处理以下一些配置参数。 +1. `CommonMiddleware` - 基础设置中间件,可以处理以下一些配置参数。 - DISALLOWED_USER_AGENTS - 不被允许的用户代理(浏览器) - APPEND_SLASH - 是否追加`/` - USE_ETAG - 浏览器缓存相关 -2. SecurityMiddleware - 安全相关中间件,可以处理和安全相关的配置项。 +2. `SecurityMiddleware` - 安全相关中间件,可以处理和安全相关的配置项。 - SECURE_HSTS_SECONDS - 强制使用HTTPS的时间 - SECURE_HSTS_INCLUDE_SUBDOMAINS - HTTPS是否覆盖子域名 - SECURE_CONTENT_TYPE_NOSNIFF - 是否允许浏览器推断内容类型 - SECURE_BROWSER_XSS_FILTER - 是否启用跨站脚本攻击过滤器 - SECURE_SSL_REDIRECT - 是否重定向到HTTPS连接 - SECURE_REDIRECT_EXEMPT - 免除重定向到HTTPS -3. SessionMiddleware - 会话中间件。 -4. CsrfViewMiddleware - 通过生成令牌,防范跨请求份伪的造中间件。 -5. XFrameOptionsMiddleware - 通过设置请求头参数,防范点击劫持攻击的中间件。 +3. `SessionMiddleware` - 会话中间件。 +4. `CsrfViewMiddleware` - 通过生成令牌,防范跨请求份伪的造中间件。 +5. `XFrameOptionsMiddleware` - 通过设置请求头参数,防范点击劫持攻击的中间件。 在请求的过程中,上面的中间件会按照书写的顺序从上到下执行,然后是URL解析,最后请求才会来到视图函数;在响应的过程中,上面的中间件会按照书写的顺序从下到上执行,与请求时中间件执行的顺序正好相反。 @@ -100,9 +51,7 @@ from django.http import JsonResponse from django.shortcuts import redirect # 需要登录才能访问的资源路径 -LOGIN_REQUIRED_URLS = { - '/praise/', '/criticize/', '/excel/', '/teachers_data/', -} +LOGIN_REQUIRED_URLS = {'/praise/', '/criticize/', '/excel/', '/teachers_data/'} def check_login_middleware(get_resp): @@ -125,7 +74,37 @@ def check_login_middleware(get_resp): return wrapper ``` -修改配置文件,激活中间件使其生效。 +当然,我们也可以定义一个类来充当装饰器,如果类中有`__call__`魔术方法,这个类的对象就像函数一样可调用,所以下面是另一种实现中间件的方式,道理跟上面的代码完全一样。 + +还有一种基于类实现中间件的方式,这种方式在较新版本的Django中已经不推荐使用了,但是大家接触到的代码中,仍然有可能遇到这种写法,大致的代码如下所示。 + +```Python +from django.utils.deprecation import MiddlewareMixin + + +class MyMiddleware(MiddlewareMixin): + + def process_request(self, request): + pass + + def process_view(self, request, view_func, view_args, view_kwargs): + pass + + def process_template_response(self, request, response): + pass + + def process_response(self, request, response): + pass + + def process_exception(self, request, exception): + pass +``` + +上面类中的五个方法都是中间件的钩子函数,分别在收到用户请求、进入视图函数之前、渲染模板、返回响应和出现异常的时候被回调。当然,写不写这些方法是根据中间件的需求来确定的,并不是所有的场景都需要重写五个方法,下面的图相信能够帮助大家理解这种写法。 + +![](res/django-middleware.png) + +写好中间件代码后,需要修改配置文件来激活中间件使其生效。 ```Python MIDDLEWARE = [ @@ -145,6 +124,3 @@ MIDDLEWARE = [ 中间件执行的顺序是非常重要的,对于有依赖关系的中间件必须保证被依赖的中间件要置于依赖它的中间件的前面,就好比我们刚才自定义的中间件要放到`SessionMiddleware`的后面,因为我们要依赖这个中间件为请求绑定的`session`对象才能判定用户是否登录。 -### 小结 - -至此,除了对用户投票数量加以限制的功能外,这个投票应用就算基本完成了,整个项目的完整代码请参考,其中用户注册时使用的手机验证码功能请大家使用自己注册的短信平台替代它。如果需要投票应用完整的视频讲解,可以在首页扫码打赏后留言联系作者获取视频下载地址,谢谢大家的理解和支持。 \ No newline at end of file diff --git a/Day41-55/48.前后端分离开发入门.md b/Day41-55/48.前后端分离开发入门.md index 2e0879e..bd41eaa 100644 --- a/Day41-55/48.前后端分离开发入门.md +++ b/Day41-55/48.前后端分离开发入门.md @@ -1,6 +1,6 @@ ## 前后端分离开发入门 -在传统的Web应用开发中,大多数的程序员会将浏览器作为前后端的分界线。将浏览器中为用户进行页面展示的部分称之为前端,而将运行在服务器,为前端提供业务逻辑和数据准备的所有代码统称为后端。所谓前后端分离的开发,就是前后端工程师约定好数据交互接口,并行的进行开发和测试,后端只提供数据,不负责将数据渲染到页面上,前端通过HTTP请求获取数据并负责将数据渲染到页面上,这个工作是交给浏览器中的JavaScript代码来完成。 +在传统的Web应用开发中,大多数的程序员会将浏览器作为前后端的分界线。将浏览器中为用户进行页面展示的部分称之为前端,而将运行在服务器为前端提供业务逻辑和数据准备的所有代码统称为后端。所谓前后端分离的开发,就是前后端工程师约定好数据交互接口,并行的进行开发和测试,后端只提供数据,不负责将数据渲染到页面上,前端通过HTTP请求获取数据并负责将数据渲染到页面上,这个工作是交给浏览器中的JavaScript代码来完成。 使用前后端分离开发有诸多的好处,下面我们简要的说下这些好处: @@ -30,9 +30,9 @@ def show_subjects(request): 上面的代码中,我们通过循环遍历查询学科得到的`QuerySet`对象,将每个学科的数据处理成一个字典,在将字典保存在名为`subjects`的列表容器中,最后利用`JsonResponse`完成对列表的序列化,向浏览器返回JSON格式的数据。由于`JsonResponse`序列化的是一个列表而不是字典,所以需要指定`safe`参数的值为`False`才能完成对`subjects`的序列化,否则会产生`TypeError`异常。 -可能大家已经发现了,自己写代码将一个对象转成字典是比较麻烦的,如果对象的属性很多而且某些属性又关联到一个比较复杂的对象时,情况会变得更加糟糕。为此我们可以使用一个名为bpmappers的三方库来简化将对象转成字典的操作,这个三方库本身也提供了对Django框架的支持。 +可能大家已经发现了,自己写代码将一个对象转成字典是比较麻烦的,如果对象的属性很多而且某些属性又关联到一个比较复杂的对象时,情况会变得更加糟糕。为此我们可以使用一个名为`bpmappers`的三方库来简化将对象转成字典的操作,这个三方库本身也提供了对Django框架的支持。 -安装三方库bpmappers。 +安装三方库`bpmappers`。 ```Shell pip install bpmappers @@ -63,15 +63,24 @@ def show_subjects(request): return JsonResponse(subjects, safe=False) ``` -配置URL映射,然后访问该接口,可以得到如下所示的JSON格式数据。 +配置URL映射。 + +```Python +urlpatterns = [ + + path('api/subjects/', show_subjects), + +] +``` + +然后访问该接口,可以得到如下所示的JSON格式数据。 ```JSON [ { - "no": 101, + "no": 1, "name": "Python全栈+人工智能", "intro": "Python是一种计算机程序设计语言。是一种面向对象的动态类型语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的、大型项目的开发。", - "create_date": "2017-08-01", "is_hot": true }, // 此处省略下面的内容 @@ -92,7 +101,7 @@ class SubjectMapper(ModelMapper): class Meta: model = Subject - exclude = ('create_date', 'is_hot') + exclude = ('is_hot', ) ``` 再次查看学科接口返回的JSON数据。 @@ -109,11 +118,11 @@ class SubjectMapper(ModelMapper): ] ``` -关于bpmappers详细的使用指南,请参考它的[官方文档](),这个官方文档是用日语书写的,可以使用浏览器的翻译功能将它翻译成你熟悉的语言即可。 +关于`bpmappers`详细的使用指南,请参考它的[官方文档](),这个官方文档是用日语书写的,可以使用浏览器的翻译功能将它翻译成你熟悉的语言即可。 ### 使用Vue.js渲染页面 -关于Vue.js的知识,我们在第21天到第30天的内容中已经介绍过了,这里我们不再进行赘述。如果希望全面的了解和学习Vue.js,建议阅读它的[官方教程]()或者在[YouTube]()上搜索Vue.js的新手教程(Crash Course)进行学习。 +接下来我们通过前端框架Vue.js来实现页面的渲染。如果希望全面的了解和学习Vue.js,建议阅读它的[官方教程]()或者在[YouTube]()上搜索Vue.js的新手教程(Vue.js Crash Course)进行学习。 重新改写subjects.html页面,使用Vue.js来渲染页面。 @@ -122,36 +131,40 @@ class SubjectMapper(ModelMapper): - 学科 + 学科信息 + -

所有学科

-
-
-
-

- {{ subject.name }} - -

-

{{ subject.intro }}

+
+

扣丁学堂所有学科

+
+
+
+
+ + {{ subject.name }} + + +
+
{{ subject.intro }}
+
- + @@ -161,4 +174,5 @@ class SubjectMapper(ModelMapper): 前后端分离的开发需要将前端页面作为静态资源进行部署,项目实际上线的时候,我们会对整个Web应用进行动静分离,静态资源通过Nginx或Apache服务器进行部署,生成动态内容的Python程序部署在uWSGI或者Gunicorn服务器上,对动态内容的请求由Nginx或Apache路由到uWSGI或Gunicorn服务器上。 -在开发阶段,我们通常会使用Django自带的测试服务器,如果要尝试前后端分离,可以先将静态页面放在之前创建的放静态资源的目录下,具体的做法可以参考[项目完整代码]()。 \ No newline at end of file +在开发阶段,我们通常会使用Django自带的测试服务器,如果要尝试前后端分离,可以先将静态页面放在之前创建的放静态资源的目录下,具体的做法可以参考[项目完整代码](https://gitee.com/jackfrued/django19062)。 + diff --git a/Day41-55/49.RESTful架构和DRF入门.md b/Day41-55/49.RESTful架构和DRF入门.md index 1af876f..1c2d7a7 100644 --- a/Day41-55/49.RESTful架构和DRF入门.md +++ b/Day41-55/49.RESTful架构和DRF入门.md @@ -1,4 +1,353 @@ ## RESTful架构和DRF入门 +把软件(Software)、平台(Platform)、基础设施(Infrastructure)做成服务(Service)是很多IT企业都一直在做的事情,这就是大家经常听到的SasS(软件即服务)、PasS(平台即服务)和IasS(基础设置即服务)。实现面向服务的架构(SOA)有诸多的方式,包括RPC(远程过程调用)、Web Service、REST等,在技术层面上,SOA是一种**抽象的、松散耦合的粗粒度软件架构**;在业务层面上,SOA的核心概念是“**重用**”和“**互操作**”,它将系统资源整合成可操作的、标准的服务,使得这些资源能够被重新组合和应用。在实现SOA的诸多方案中,REST被认为是最适合互联网应用的架构,符合REST规范的架构也经常被称作RESTful架构。 + +### REST概述 + +REST这个词,是**Roy Thomas Fielding**在他2000年的博士论文中提出的,Roy是HTTP协议(1.0和1.1版)的主要设计者、Apache服务器软件主要作者、Apache基金会第一任主席。在他的博士论文中,Roy把他对互联网软件的架构原则定名为REST,即**RE**presentational **S**tate **T**ransfer的缩写,中文通常翻译为“**表现层状态转移**”或“**表述状态转移**”。 + +这里的“表现层”其实指的是“资源”的“表现层”。所谓资源,就是网络上的一个实体,或者说是网络上的一个具体信息。它可以是一段文本、一张图片、一首歌曲或一种服务。我们可以用一个URI(统一资源定位符)指向资源,要获取到这个资源,访问它的URI即可,URI就是资源在互联网上的唯一标识。资源可以有多种外在表现形式。我们把资源具体呈现出来的形式,叫做它的“表现层”。比如,文本可以用`text/plain`格式表现,也可以用`text/html`格式、`text/xml`格式、`application/json`格式表现,甚至可以采用二进制格式;图片可以用`image/jpeg`格式表现,也可以用`image/png`格式表现。URI只代表资源的实体,不代表它的表现形式。严格地说,有些网址最后的`.html`后缀名是不必要的,因为这个后缀名表示格式,属于“表现层”范畴,而URI应该只代表“资源”的位置,它的具体表现形式,应该在HTTP请求的头信息中用`Accept`和`Content-Type`字段指定,这两个字段才是对“表现层”的描述。 + +访问一个网站,就代表了客户端和服务器的一个互动过程。在这个过程中,势必涉及到数据和状态的变化。Web应用通常使用HTTP作为其通信协议,客户端想要操作服务器,必须通过HTTP请求,让服务器端发生“状态转移”,而这种转移是建立在表现层之上的,所以就是“表现层状态转移”。客户端通过HTTP的动词GET、POST、PUT(或PATCH)、DELETE,分别对应对资源的四种基本操作,其中GET用来获取资源,POST用来新建资源(也可以用于更新资源),PUT(或PATCH)用来更新资源,DELETE用来删除资源。 + +简单的说RESTful架构就是:“每一个URI代表一种资源,客户端通过四个HTTP动词,对服务器端资源进行操作,实现资源的表现层状态转移”。 + +我们在设计Web应用时,如果需要向客户端提供资源,就可以使用REST风格的URI,这是实现RESTful架构的第一步。当然,真正的RESTful架构并不只是URI符合REST风格,更为重要的是“无状态”和“幂等性”两个词,我们在后面的课程中会为大家阐述这两点。下面的例子给出了一些符合REST风格的URI,供大家在设计URI时参考。 + +| 请求方法(HTTP动词) | URI | 解释 | +| -------------------- | -------------------------- | -------------------------------------------- | +| **GET** | `/students/` | 获取所有学生 | +| **POST** | `/students/` | 新建一个学生 | +| **GET** | `/students/ID/` | 获取指定ID的学生信息 | +| **PUT** | `/students/ID/` | 更新指定ID的学生信息(提供该学生的全部信息) | +| **PATCH** | `/students/ID/` | 更新指定ID的学生信息(提供该学生的部分信息) | +| **DELETE** | `/students/ID/` | 删除指定ID的学生信息 | +| **GET** | `/students/ID/friends/` | 列出指定ID的学生的所有朋友 | +| **DELETE** | `/students/ID/friends/ID/` | 删除指定ID的学生的指定ID的朋友 | + +### DRF使用入门 + +在Django项目中,如果要实现REST架构,即将网站的资源发布成REST风格的API接口,可以使用著名的三方库`djangorestframework` ,我们通常将其简称为DRF。 + +#### 安装和配置DRF + +安装DRF。 + +```Shell +pip install djangorestframework +``` + +配置DRF。 + +```Python +INSTALLED_APPS = [ + + 'rest_framework', + +] + +# 下面的配置根据项目需要进行设置 +REST_FRAMEWORK = { + # 配置默认页面大小 + # 'PAGE_SIZE': 10, + # 配置默认的分页类 + # 'DEFAULT_PAGINATION_CLASS': '...', + # 配置异常处理器 + # 'EXCEPTION_HANDLER': '...', + # 配置默认解析器 + # 'DEFAULT_PARSER_CLASSES': ( + # 'rest_framework.parsers.JSONParser', + # 'rest_framework.parsers.FormParser', + # 'rest_framework.parsers.MultiPartParser', + # ), + # 配置默认限流类 + # 'DEFAULT_THROTTLE_CLASSES': ( + # '...' + # ), + # 配置默认授权类 + # 'DEFAULT_PERMISSION_CLASSES': ( + # '...', + # ), + # 配置默认认证类 + # 'DEFAULT_AUTHENTICATION_CLASSES': ( + # '...', + # ), +} +``` + +#### 编写序列化器 + +前后端分离的开发需要后端为前端、移动端提供API数据接口,而API接口通常情况下都是返回JSON格式的数据,这就需要对模型对象进行序列化处理。DRF中封装了`Serializer`类和`ModelSerializer`类用于实现序列化操作,通过继承`Serializer`类或`ModelSerializer`类,我们可以自定义序列化器,用于将对象处理成字典,代码如下所示。 + +```Python +from rest_framework import serializers +class SubjectSerializer(serializers.ModelSerializer): + + class Meta: + model = Subject + fields = '__all__' +``` + +上面的代码直接继承了`ModelSerializer`,通过`Meta`类的`model`属性指定要序列化的模型以及`fields`属性指定需要序列化的模型字段,稍后我们就可以在视图函数中使用该类来实现对`Subject`模型的序列化。 + +#### 编写视图函数 + +DRF框架支持两种实现数据接口的方式,一种是FBV(基于函数的视图),另一种是CBV(基于类的视图)。我们先看看FBV的方式如何实现数据接口,代码如下所示。 + +```Python +from rest_framework.decorators import api_view +from rest_framework.response import Response + + +@api_view(('GET', )) +def show_subjects(request: HttpRequest) -> HttpResponse: + subjects = Subject.objects.all().order_by('no') + # 创建序列化器对象并指定要序列化的模型 + serializer = SubjectSerializer(subjects, many=True) + # 通过序列化器的data属性获得模型对应的字典并通过创建Response对象返回JSON格式的数据 + return Response(serializer.data) +``` + +对比上一个章节的使用`bpmapper`实现模型序列化的代码,使用DRF的代码更加简单明了,而且DRF本身自带了一套页面,可以方便我们查看我们使用DRF定制的数据接口,如下图所示。 + +![](res/drf-app.png) + +直接使用上一节写好的页面,就可以通过Vue.js把上面接口提供的学科数据渲染并展示出来,此处不再进行赘述。 + +#### 实现老师信息数据接口 + +编写序列化器。 + +```Python +class SubjectSimpleSerializer(serializers.ModelSerializer): + + class Meta: + model = Subject + fields = ('no', 'name') + + +class TeacherSerializer(serializers.ModelSerializer): + + class Meta: + model = Teacher + exclude = ('subject', ) +``` + +编写视图函数。 + +```Python +@api_view(('GET', )) +def show_teachers(request: HttpRequest) -> HttpResponse: + try: + sno = int(request.GET.get('sno')) + subject = Subject.objects.only('name').get(no=sno) + teachers = Teacher.objects.filter(subject=subject).defer('subject').order_by('no') + subject_seri = SubjectSimpleSerializer(subject) + teacher_seri = TeacherSerializer(teachers, many=True) + return Response({'subject': subject_seri.data, 'teachers': teacher_seri.data}) + except (TypeError, ValueError, Subject.DoesNotExist): + return Response(status=404) +``` + +配置URL映射。 + +```Python +urlpatterns = [ + + path('api/teachers/', show_teachers), + +] +``` + +通过Vue.js渲染页面。 + +```HTML + + + + + 老师信息 + + + +
+

{{ subject.name }}学科的老师信息

+
+

暂无该学科老师信息

+
+
+ +
+
+
+ 姓名:{{ teacher.name }} + 性别:{{ teacher.sex | maleOrFemale }} + 出生日期:{{ teacher.birth }} +
+
{{ teacher.intro }}
+
+ 好评   + ({{ teacher.good_count }}) +      + 差评   + ({{ teacher.bad_count }}) +
+
+
+ 返回首页 +
+ + + + +``` + +### 前后端分离下的用户登录 + +之前我们提到过, HTTP是无状态的,一次请求结束连接断开,下次服务器再收到请求,它就不知道这个请求是哪个用户发过来的。但是对于一个Web应用而言,它是需要有状态管理的,这样才能让服务器知道HTTP请求来自哪个用户,从而判断是否允许该用户请求以及为用户提供更好的服务,这个过程就是常说的**会话管理**。 + +之前我们做会话管理(用户跟踪)的方法是:用户登录成功后,在服务器端通过一个session对象保存用户相关数据,然后把session对象的ID写入浏览器的cookie中;下一次请求时,HTTP请求头中携带cookie的数据,服务器从HTTP请求头读取cookie中的sessionid,根据这个标识符找到对应的session对象,这样就能够获取到之前保存在session中的用户数据。我们刚才说过,REST架构是最适合互联网应用的架构,它强调了HTTP的无状态性,这样才能保证应用的水平扩展能力(当并发访问量增加时,可以通过增加新的服务器节点来为系统扩容)。显然,基于session实现用户跟踪的方式需要服务器保存session对象,在做水平扩展增加新的服务器节点时,需要复制和同步session对象,这显然是非常麻烦的。解决这个问题有两种方案,一种是架设缓存服务器(如Redis),让多个服务器节点共享缓存服务并将session对象直接置于缓存服务器中;另一种方式放弃基于session的用户跟踪,使用**基于token的用户跟踪**。 + +基于token的用户跟踪是在用户登录成功后,为用户生成身份标识并保存在浏览器本地存储(localStorage、sessionStorage、cookie等)中,这样的话服务器不需要保存用户状态,从而可以很容易的做到水平扩展。基于token的用户跟踪具体流程如下: + +1. 用户登录时,如果登录成功就按照某种方式为用户生成一个令牌(token),该令牌中通常包含了用户标识、过期时间等信息而且需要加密并生成指纹(避免伪造或篡改令牌),服务器将令牌返回给前端; +2. 前端获取到服务器返回的token,保存在浏览器本地存储中(可以保存在`localStorage`或`sessionStorage`中,对于使用Vue.js的前端项目来说,还可以通过Vuex进行状态管理); +3. 对于使用了前端路由的项目来说,前端每次路由跳转,可以先判断`localStroage`中有无token,如果没有则跳转到登录页; +4. 每次请求后端数据接口,在HTTP请求头里携带token;后端接口判断请求头有无token,如果没有token以及token是无效的或过期的,服务器统一返回401; +5. 如果前端收到HTTP响应状态码401,则重定向到登录页面。 + +通过上面的描述,相信大家已经发现了,基于token的用户跟踪最为关键是在用户登录成功时,要为用户生成一个token作为用户的身份标识。生成token的方法很多,其中一种比较成熟的解决方案是使用JSON Web Token。 + +#### JWT概述 + +JSON Web Token通常简称为JWT,它是一种开放标准(RFC 7519)。随着RESTful架构的流行,越来越多的项目使用JWT作为用户身份认证的方式。JWT相当于是三个JSON对象经过编码后,用`.`分隔并组合到一起,这三个JSON对象分别是头部(header)、载荷(payload)和签名(signature),如下图所示。 + +![](res/json-web-token.png) + +1. 头部 + + ```JSON + { + "alg": "HS256", + "typ": "JWT" + } + ``` + + 其中,`alg`属性表示签名的算法,默认是HMAC SHA256(简写成`HS256`);`typ`属性表示这个令牌的类型,JWT中都统一书写为`JWT`。 + +2. 载荷 + + 载荷部分用来存放实际需要传递的数据。JWT官方文档中规定了7个可选的字段: + + - iss :签发人 + - exp:过期时间 + - sub:主题 + - aud:受众 + - nbf:生效时间 + - iat:签发时间 + - jti:编号 + + 除了官方定义的字典,我们可以根据应用的需要添加自定义的字段,如下所示。 + + ```JSON + { + "sub": "1234567890", + "nickname": "jackfrued", + "role": "admin" + } + ``` + +3. 签名 + + 签名部分是对前面两部分生成一个指纹,防止数据伪造和篡改。实现签名首先需要指定一个密钥。这个密钥只有服务器才知道,不能泄露给用户。然后,使用头部指定的签名算法(默认是`HS256`),按照下面的公式产生签名。 + + ```Python + HS256(base64Encode(header) + '.' + base64Encode(payload), secret) + ``` + + 算出签名以后,把头部、载荷、签名三个部分拼接成一个字符串,每个部分用`.`进行分隔,这样一个JWT就生成好了。 + +#### JWT的优缺点 + +使用JWT的优点非常明显,包括: + +1. 更容易实现水平扩展,因为令牌保存在浏览器中,服务器不需要做状态管理。 +2. 更容易防范CSRF攻击,因为在请求头中添加`localStorage`或`sessionStorage`中的token必须靠JavaScript代码完成,而不是自动添加到请求头中的。 +3. 可以防伪造和篡改,因为JWT有签名,伪造和篡改的令牌无法通过签名验证,会被认定是无效的令牌。 + +当然,任何技术不可能只有优点没有缺点,JWT也有诸多缺点,大家需要在使用的时候引起注意,具体包括: + +1. 可能会遭受到XSS攻击(跨站脚本攻击),通过注入恶意脚本执行JavaScript代码获取到用户令牌。 +2. 在令牌过期之前,无法作废已经颁发的令牌,要解决这个问题,还需要额外的中间层和代码来辅助。 +3. JWT是用户的身份令牌,一旦泄露,任何人都可以获得该用户的所有权限。为了降低令牌被盗用后产生的风险,JWT的有效期应该设置得比较短。对于一些比较重要的权限,使用时应通过其他方式再次对用户进行认证,例如短信验证码等。 + +#### 使用PyJWT + +在Python代码中,可以使用三方库`PyJWT`生成和验证JWT,下面是安装`PyJWT`的命令。 + +```Bash +pip install pyjwt +``` + +生成令牌。 + +```Python +payload = { + 'exp': datetime.datetime.utcnow() + datetime.timedelta(days=1), + 'userid': 10001 +} +token = jwt.encode(payload, settings.SECRET_KEY).decode() +``` + +验证令牌。 + +```Python +try: + token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE1OTQ4NzIzOTEsInVzZXJpZCI6MTAwMDF9.FM-bNxemWLqQQBIsRVvc4gq71y42I9m2zt5nlFxNHUo' + payload = jwt.decode(token, settings.SECRET_KEY) +except InvalidTokenError: + raise AuthenticationFailed('无效的令牌或令牌已经过期') +``` + +如果不清楚JWT具体的使用方式,可以先看看第55天的内容,里面提供了完整的投票项目代码的地址。 \ No newline at end of file diff --git a/Day41-55/50.RESTful架构和DRF进阶.md b/Day41-55/50.RESTful架构和DRF进阶.md index 1325323..28083cc 100644 --- a/Day41-55/50.RESTful架构和DRF进阶.md +++ b/Day41-55/50.RESTful架构和DRF进阶.md @@ -1,4 +1,129 @@ ## RESTful架构和DRF进阶 +除了上一节讲到的方法,使用DRF创建REST风格的数据接口也可以通过CBV(基于类的视图)的方式。使用CBV创建数据接口的特点是代码简单,开发效率高,但是没有FBV(基于函数的视图)灵活,因为使用FBV的方式,数据接口对应的视图函数执行什么样的代码以及返回什么的数据是高度可定制的。下面我们以定制学科的数据接口为例,讲解通过CBV方式定制数据接口的具体做法。 + +### 使用CBV + +#### 继承APIView的子类 + +修改之前项目中的`polls/views.py`,去掉`show_subjects`视图函数,添加一个名为`SubjectView`的类,该类继承自`ListAPIView`,`ListAPIView`能接收GET请求,它封装了获取数据列表并返回JSON数据的`get`方法。`ListAPIView`是`APIView` 的子类,`APIView`还有很多的子类,例如`CreateAPIView`可以支持POST请求,`UpdateAPIView`可以支持PUT和PATCH请求,`DestoryAPIView`可以支持DELETE请求。`SubjectView` 的代码如下所示。 + +```Python +from rest_framework.generics import ListAPIView +class SubjectView(ListAPIView): + # 通过queryset指定如何获取学科数据 + queryset = Subject.objects.all() + # 通过serializer_class指定如何序列化学科数据 + serializer_class = SubjectSerializer +``` + +刚才说过,由于`SubjectView`的父类`ListAPIView`已经实现了`get`方法来处理获取学科列表的GET请求,所以我们只需要声明如何获取学科数据以及如何序列化学科数据,前者用`queryset`属性指定,后者用`serializer_class`属性指定。要使用上面的`SubjectView`,需要修改`urls.py`文件,如下所示。 + +```Python +urlpatterns = [ + path('api/subjects/', SubjectView.as_view()), +] +``` + +很显然,上面的做法较之之前讲到的FBV要简单很多。 + +#### 继承ModelViewSet + +如果学科对应的数据接口需要支持GET、POST、PUT、PATCH、DELETE请求来支持对学科资源的获取、新增、更新、删除操作,更为简单的做法是继承`ModelViewSet`来编写学科视图类。再次修改`polls/views.py`文件,去掉`SubjectView`类,添加一个名为`SubjectViewSet`的类,代码如下所示。 + +```Python +from rest_framework.viewsets import ModelViewSet + + +class SubjectViewSet(ModelViewSet): + queryset = Subject.objects.all() + serializer_class = SubjectSerializer +``` + +通过查看`ModelViewSet`类的源代码可以发现,该类共有6个父类,其中前5个父类分别实现对POST(新增学科)、GET(获取指定学科)、PUT/PATCH(更新学科)、DELETE(删除学科)和GET(获取学科列表)操作的支持,对应的方法分别是`create`、`retrieve`、`update`、`destroy`和`list`。由于`ModelViewSet`的父类中已经实现了这些方法,所以我们几乎没有编写任何代码就完成了学科数据全套接口的开发,我们要做的仅仅是指出如何获取到数据(通过`queryset`属性指定)以及如何序列化数据(通过`serializer_class`属性指定),这一点跟上面继承`APIView`的子类做法是一致的。 + +```Python +class ModelViewSet(mixins.CreateModelMixin, + mixins.RetrieveModelMixin, + mixins.UpdateModelMixin, + mixins.DestroyModelMixin, + mixins.ListModelMixin, + GenericViewSet): + """ + A viewset that provides default `create()`, `retrieve()`, `update()`, + `partial_update()`, `destroy()` and `list()` actions. + """ + pass +``` + +要使用上面的`SubjectViewSet`,需要在`urls.py`文件中进行URL映射。由于`ModelViewSet`相当于是多个视图函数的汇总,所以不同于之前映射URL的方式,我们需要先创建一个路由器并通过它注册`SubjectViewSet`,然后将注册成功后生成的URL一并添加到`urlspattern`列表中,代码如下所示。 + +```Python +from rest_framework.routers import DefaultRouter + +router = DefaultRouter() +router.register('api/subjects', SubjectViewSet) +urlpatterns += router.urls +``` + +除了`ModelViewSet`类外,DRF还提供了一个名为`ReadOnlyModelViewSet` 的类,从名字上就可以看出,该类是只读视图的集合,也就意味着,继承该类定制的数据接口只能支持GET请求,也就是获取单个资源和资源列表的请求。 + +### 数据分页 + +在使用GET请求获取资源列表时,我们通常不会一次性的加载所有的数据,除非数据量真的很小。大多数获取资源列表的操作都支持数据分页展示,也就说我们可以通过指定页码(或类似于页码的标识)和页面大小(一次加载多少条数据)来获取不同的数据。我们可以通过对`QuerySet`对象的切片操作来实现分页,也可以利用Django框架封装的`Paginator`和`Page`对象来实现分页。使用DRF时,可以在Django配置文件中修改`REST_FRAMEWORK`并配置默认的分页类和页面大小来实现分页,如下所示。 + +```Python +REST_FRAMEWORK = { + 'PAGE_SIZE': 10, + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination' +} +``` + +除了上面配置的`PageNumberPagination`分页器之外,DRF还提供了`LimitOffsetPagination`和`CursorPagination`分页器,值得一提的是`CursorPagination`,它可以避免使用页码分页时暴露网站的数据体量,有兴趣的读者可以自行了解。如果不希望使用配置文件中默认的分页设定,可以在视图类中添加一个`pagination_class`属性来重新指定分页器,通常可以将该属性指定为自定义的分页器,如下所示。 + +```Python +from rest_framework.pagination import PageNumberPagination + + +class CustomizedPagination(PageNumberPagination): + # 默认页面大小 + page_size = 5 + # 页面大小对应的查询参数 + page_size_query_param = 'size' + # 页面大小的最大值 + max_page_size = 50 +``` + +```Python +class SubjectView(ListAPIView): + # 指定如何获取数据 + queryset = Subject.objects.all() + # 指定如何序列化数据 + serializer_class = SubjectSerializer + # 指定如何分页 + pagination_class = CustomizedPagination +``` + +如果不希望数据分页,可以将`pagination_class`属性设置为`None`来取消默认的分页器。 + +### 数据筛选 + +如果希望使用CBV定制获取老师信息的数据接口,也可以通过继承`ListAPIView`来实现。但是因为要通过指定的学科来获取对应的老师信息,因此需要对老师数据进行筛选而不是直接获取所有老师的数据。如果想从请求中获取学科编号并通过学科编号对老师进行筛选,可以通过重写`get_queryset`方法来做到,代码如下所示。 + +```Python +class TeacherView(ListAPIView): + serializer_class = TeacherSerializer + + def get_queryset(self): + queryset = Teacher.objects.defer('subject') + try: + sno = self.request.GET.get('sno', '') + queryset = queryset.filter(subject__no=sno) + return queryset + except ValueError: + raise Http404('No teachers found.') +``` + +除了上述方式之外,还可以使用三方库`django-filter`来配合DRF实现对数据的筛选,使用`django-filter`后,可以通过为视图类配置`filter-backends`属性并指定使用`DjangoFilterBackend`来支持数据筛选。在完成上述配置后,可以使用`filter_fields` 属性或`filterset_class`属性来指定如何筛选数据,有兴趣的读者可以自行研究。 \ No newline at end of file diff --git a/Day41-55/51.使用缓存.md b/Day41-55/51.使用缓存.md index ee55bf6..7e39e08 100644 --- a/Day41-55/51.使用缓存.md +++ b/Day41-55/51.使用缓存.md @@ -1,4 +1,147 @@ ## 使用缓存 +通常情况下,Web应用的性能瓶颈都会出现在关系型数据库上,当并发访问量较大时,如果所有的请求都需要通过关系型数据库完成数据持久化操作,那么数据库一定会不堪重负。优化Web应用性能最为重要的一点就是使用缓存,把那些数据体量不大但访问频率非常高的数据提前加载到缓存服务器中,这又是典型的空间换时间的方法。通常缓存服务器都是直接将数据置于内存中而且使用了非常高效的数据存取策略(哈希存储、键值对方式等),在读写性能上远远优于关系型数据库的,因此我们可以让Web应用接入缓存服务器来优化其性能,其中一个非常好的选择就是使用Redis。 + +Web应用的缓存架构大致如下图所示。 + +![](res/redis-cache-service.png) + +### Django项目接入Redis + +在此前的课程中,我们介绍过Redis的安装和使用,此处不再进行赘述。如果需要在Django项目中接入Redis,可以使用三方库`django-redis`,这个三方库又依赖了一个名为`redis` 的三方库,它封装了对Redis的各种操作。 + +安装`django-redis`。 + +```Bash +pip install django-redis +``` + +修改Django配置文件中关于缓存的配置。 + +```Python +CACHES = { + 'default': { + # 指定通过django-redis接入Redis服务 + 'BACKEND': 'django_redis.cache.RedisCache', + # Redis服务器的URL + 'LOCATION': ['redis://1.2.3.4:6379/0', ], + # Redis中键的前缀(解决命名冲突) + 'KEY_PREFIX': 'vote', + # 其他的配置选项 + 'OPTIONS': { + 'CLIENT_CLASS': 'django_redis.client.DefaultClient', + # 连接池(预置若干备用的Redis连接)参数 + 'CONNECTION_POOL_KWARGS': { + # 最大连接数 + 'max_connections': 512, + }, + # 连接Redis的用户口令 + 'PASSWORD': 'foobared', + } + }, +} +``` + +至此,我们的Django项目已经可以接入Redis,接下来我们修改项目代码,用Redis为之写的获取学科数据的接口提供缓存服务。 + +### 为视图提供缓存服务 + +#### 声明式缓存 + +所谓声明式缓存是指不修改原来的代码,通过Python中的装饰器(代理)为原有的代码增加缓存功能。对于FBV,代码如下所示。 + +```Python +from django.views.decorators.cache import cache_page +@api_view(('GET', )) +@cache_page(timeout=86400, cache='default') +def show_subjects(request): + """获取学科数据""" + queryset = Subject.objects.all() + data = SubjectSerializer(queryset, many=True).data + return Response({'code': 20000, 'subjects': data}) +``` + +上面的代码通过Django封装的`cache_page`装饰器缓存了视图函数的返回值(响应对象),`cache_page`的本意是缓存视图函数渲染的页面,对于返回JSON数据的视图函数,相当于是缓存了JSON数据。在使用`cache_page`装饰器时,可以传入`timeout`参数来指定缓存过期时间,还可以使用`cache`参数来指定需要使用哪一组缓存服务来缓存数据。Django项目允许在配置文件中配置多组缓存服务,上面的`cache='default'`指定了使用默认的缓存服务(因为之前的配置文件中我们也只配置了名为`default`的缓存服务)。视图函数的返回值会被序列化成字节串放到Redis中(Redis中的str类型可以接收字节串),缓存数据的序列化和反序列化也不需要我们自己处理,因为`cache_page`装饰器会调用`django-redis`库中的`RedisCache`来对接Redis,该类使用了`DefaultClient`来连接Redis并使用了[pickle序列化](https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p21_serializing_python_objects.html),`django_redis.serializers.pickle.PickleSerializer`是默认的序列化类。 + +如果缓存中没有学科的数据,那么通过接口访问学科数据时,我们的视图函数会通过执行`Subject.objects.all()`向数据库发出SQL语句来获得数据,视图函数的返回值会被缓存,因此下次请求该视图函数如果缓存没有过期,可以直接从缓存中获取视图函数的返回值,无需再次查询数据库。如果想了解缓存的使用情况,可以配置数据库日志或者使用Django-Debug-Toolbar来查看,第一次访问学科数据接口时会看到查询学科数据的SQL语句,再次获取学科数据时,不会再向数据库发出SQL语句,因为可以直接从缓存中获取数据。 + +对于CBV,可以利用Django中名为`method_decorator`的装饰器将`cache_page`这个装饰函数的装饰器放到类中的方法上,效果跟上面的代码是一样的。需要提醒大家注意的是,`cache_page`装饰器不能直接放在类上,因为它是装饰函数的装饰器,所以Django框架才提供了`method_decorator`来解决这个问题,很显然,`method_decorator`是一个装饰类的装饰器。 + +```Python +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page + + +@method_decorator(decorator=cache_page(timeout=86400, cache='default'), name='get') +class SubjectView(ListAPIView): + """获取学科数据的视图类""" + queryset = Subject.objects.all() + serializer_class = SubjectSerializer +``` + +#### 编程式缓存 + +所谓编程式缓存是指通过自己编写的代码来使用缓存服务,这种方式虽然代码量会稍微大一些,但是相较于声明式缓存,它对缓存的操作和使用更加灵活,在实际开发中使用得更多。下面的代码去掉了之前使用的`cache_page`装饰器,通过`django-redis`提供的`get_redis_connection`函数直接获取Redis连接来操作Redis。 + +```Python +def show_subjects(request): + """获取学科数据""" + redis_cli = get_redis_connection() + # 先尝试从缓存中获取学科数据 + data = redis_cli.get('vote:polls:subjects') + if data: + # 如果获取到学科数据就进行反序列化操作 + data = json.loads(data) + else: + # 如果缓存中没有获取到学科数据就查询数据库 + queryset = Subject.objects.all() + data = SubjectSerializer(queryset, many=True).data + # 将查到的学科数据序列化后放到缓存中 + redis_cli.set('vote:polls:subjects', json.dumps(data), ex=86400) + return Response({'code': 20000, 'subjects': data}) +``` + +需要说明的是,Django框架提供了`cache`和`caches`两个现成的变量来支持缓存操作,前者访问的是默认的缓存(名为`default`的缓存),后者可以通过索引运算获取指定的缓存服务(例如:`caches['default']`)。向`cache`对象发送`get`和`set`消息就可以实现对缓存的读和写操作,但是这种方式能做的操作有限,不如上面代码中使用的方式灵活。还有一个值得注意的地方,由于可以通过`get_redis_connection`函数获得的Redis连接对象向Redis发起各种操作,包括`FLUSHDB`、`SHUTDOWN`等危险的操作,所以在实际商业项目开发中,一般都会对`django-redis`再做一次封装,例如封装一个工具类,其中只提供了项目需要用到的缓存操作的方法,从而避免了直接使用`get_redis_connection`的潜在风险。当然,自己封装对缓存的操作还可以使用“Read Through”和“Write Through”的方式实现对缓存的更新,这个在下面会介绍到。 + +### 缓存相关问题 + +#### 缓存数据的更新 + +在使用缓存时,一个必须搞清楚的问题就是,当数据改变时,如何更新缓存中的数据。通常更新缓存有如下几种套路,分别是: + +1. Cache Aside Pattern +2. Read/Write Through Pattern +3. Write Behind Caching Pattern + +第1种方式的具体做法就是,当数据更新时,先更新数据库,再删除缓存。注意,不能够使用先更新数据库再更新缓存的方式,也不能够使用先删除缓存再更新数据库的方式,大家可以自己想一想为什么(考虑一下有并发的读操作和写操作的场景)。当然,先更新数据库再删除缓存的做法在理论上也存在风险,但是发生问题的概率是极低的,所以不少的项目都使用了这种方式。 + +第1种方式相当于编写业务代码的开发者要自己负责对两套存储系统(缓存和关系型数据库)的操作,代码写起来非常的繁琐。第2种方式的主旨是将后端的存储系统变成一套代码,对缓存的维护封装在这套代码中。其中,Read Through指在查询操作中更新缓存,也就是说,当缓存失效的时候,由缓存服务自己负责对数据的加载,从而对应用方是透明的;而Write Through是指在更新数据时,如果没有命中缓存,直接更新数据库,然后返回。如果命中了缓存,则更新缓存,然后再由缓存服务自己更新数据库(同步更新)。刚才我们说过,如果自己对项目中的Redis操作再做一次封装,就可以实现“Read Through”和“Write Through”模式,这样做虽然会增加工作量,但无疑是一件“一劳永逸”且“功在千秋”的事情。 + +第3种方式是在更新数据的时候,只更新缓存,不更新数据库,而缓存服务这边会**异步的批量更新**数据库。这种做法会大幅度提升性能,但代价是牺牲数据的**强一致性**。第3种方式的实现逻辑比较复杂,因为他需要追踪有哪数据是被更新了的,然后再批量的刷新到持久层上。 + +#### 缓存穿透 + +缓存是为了缓解数据库压力而添加的一个中间层,如果恶意的访问者频繁的访问缓存中没有的数据,那么缓存就失去了存在的意义,瞬间所有请求的压力都落在了数据库上,这样会导致数据库承载着巨大的压力甚至连接异常,类似于分布式拒绝服务攻击(DDoS)的做法。解决缓存穿透的一个办法是约定如果查询返回为空值,把这个空值也缓存起来,但是需要为这个空值的缓存设置一个较短的超时时间,毕竟缓存这样的值就是对缓存空间的浪费。另一个解决缓存穿透的办法是使用布隆过滤器,具体的做法大家可以自行了解。 + +#### 缓存击穿 + +在实际的项目中,可能存在某个缓存的key某个时间点过期,但恰好在这个时间点对有对该key的大量的并发请求过来,这些请求没有从缓存中找到key对应的数据,就会直接从数据库中获取数据并写回到缓存,这个时候大并发的请求可能会瞬间把数据库压垮,这种现象称为缓存击穿。比较常见的解决缓存击穿的办法是使用互斥锁,简单的说就是在缓存失效的时候,不是立即去数据库加载数据,而是先设置互斥锁(例如:Redis中的setnx),只有设置互斥锁的操作成功的请求,才能执行查询从数据库中加载数据并写入缓存,其他设置互斥锁失败的请求,可以先执行一个短暂的休眠,然后尝试重新从缓存中获取数据,如果缓存还没有数据,则重复刚才的设置互斥锁的操作,大致的参考代码如下所示。 + +```Python +data = redis_cli.get(key) +while not data: + if redis_cli.setnx('mutex', 'x'): + redis.expire('mutex', timeout) + data = db.query(...) + redis.set(key, data) + redis.delete('mutex') + else: + time.sleep(0.1) + data = redis_cli.get(key) +``` + +#### 缓存雪崩 + +缓存雪崩是指在将数据放入缓存时采用了相同的过期时间,这样就导致缓存在某一时刻同时失效,请求全部转发到数据库,导致数据库瞬时压力过大而崩溃。解决缓存雪崩问题的方法也比较简单,可以在既定的缓存过期时间上加一个随机时间,这样可以从一定程度上避免不同的key在同一时间集体失效。还有一种办法就是使用多级缓存,每一级缓存的过期时间都不一样,这样的话即便某个级别的缓存集体失效,但是其他级别的缓存还能够提供数据,避免所有的请求都落到数据库上。 \ No newline at end of file diff --git a/Day41-55/52.接入三方平台.md b/Day41-55/52.接入三方平台.md new file mode 100644 index 0000000..b6094cf --- /dev/null +++ b/Day41-55/52.接入三方平台.md @@ -0,0 +1,201 @@ +## 接入三方平台 + +在Web应用的开发过程中,有一些任务并不是我们自己能够完成的。例如,我们的Web项目中需要做个人或企业的实名认证,很显然我们并没有能力判断用户提供的认证信息的真实性,这个时候我们就要借助三方平台提供的服务来完成该项操作。再比如说,我们的项目中需要提供在线支付功能,这类业务通常也是借助支付网关来完成而不是自己去实现,我们只需要接入像微信、支付宝、银联这样的三方平台即可。 + +在项目中接入三方平台基本上就两种方式:API接入和SDK接入。 + +1. API接入指的是通过访问三方提供的URL来完成操作或获取数据。国内有很多这样的平台提供了大量常用的服务,例如[聚合数据](https://www.juhe.cn/)上提供了生活服务类、金融科技类、交通地理类、充值缴费类等各种类型的API。我们可以通过Python程序发起网络请求,通过访问URL获取数据,这些API接口跟我们项目中提供的数据接口是一样的,只不过我们项目中的API是供自己使用的,而这类三方平台提供的API是开放的。当然开放并不代表免费,大多数能够提供有商业价值的数据的API都是需要付费才能使用的。 +2. SDK接入指的是通过安装三方库并使用三方库封装的类、函数来使用三方平台提供的服务的方式。例如我们刚才说到的接入支付宝,就需要先安装支付宝的SDK,然后通过支付宝封装的类和方法完成对支付服务的调用。 + +下面我们通过具体的例子来讲解如何接入三方平台。 + +### 接入短信网关 + +一个Web项目有很多地方都可以用到短信服务,例如:手机验证码登录、重要消息提醒、产品营销短信等。要实现发送短信的功能,可以通过接入短信网关来实现,国内比较有名的短信网关包括:云片短信、网易云信、螺丝帽、SendCloud等,这些短信网关一般都提供了免费试用功能。下面我们以[螺丝帽](https://luosimao.com/)平台为例,讲解如何在项目中接入短信网关,其他平台操作基本类似。 + +1. 注册账号,新用户可以免费试用。 + +2. 登录到管理后台,进入短信版块。 + +3. 点击“触发发送”可以找到自己专属的API Key(身份标识)。 + + ![](res/luosimao-sms-apikey.png) + +4. 点击“签名管理”可以添加短信签名,短信都必须携带签名,免费试用的短信要在短信中添加“【铁壳测试】”这个签名,否则短信无法发送。 + + ![](res/luosimao-sms-signature.png) + +5. 点击“IP白名单”将运行Django项目的服务器地址(公网IP地址,本地运行可以打开[xxx]()网站查看自己本机的公网IP地址)填写到白名单中,否则短信无法发送。 + + ![](res/luosimao-sms-whitelist.png) + +6. 如果没有剩余的短信条数,可以到“充值”页面选择“短信服务”进行充值。 + + ![](res/luosimao-pay-onlinebuy.png) + +接下来,我们可以通过调用螺丝帽短信网关实现发送短信验证码的功能,代码如下所示。 + +```Python +def send_mobile_code(tel, code): + """发送短信验证码""" + resp = requests.post( + url='http://sms-api.luosimao.com/v1/send.json', + auth=('api', 'key-自己的APIKey'), + data={ + 'mobile': tel, + 'message': f'您的短信验证码是{code},打死也不能告诉别人哟。【Python小课】' + }, + verify=False + ) + return resp.json() +``` + +运行上面的代码需要先安装`requests`三方库,这个三方库封装了HTTP网络请求的相关功能,使用起来非常的简单,我们在之前的内容中也讲到过这个三方库。`send_mobile_code`函数有两个参数,第一个参数是手机号,第二个参数是短信验证码的内容,第5行代码需要提供自己的API Key,就是上面第2步中查看到的自己的API Key。请求螺丝帽的短信网关会返回JSON格式的数据,对于上面的代码如果返回`{'err': 0, 'msg': 'ok'}`,则表示短信发送成功,如果`err`字段的值不为`0`而是其他值,则表示短信发送失败,可以在螺丝帽官方的[开发文档](https://luosimao.com/docs/api/)页面上查看到不同的数值代表的含义,例如:`-20`表示余额不足,`-32`表示缺少短信签名。 + +可以在视图函数中调用上面的函数来完成发送短信验证码的功能,稍后我们可以把这个功能跟用户注册结合起来。 + +生成随机验证码和验证手机号的函数。 + +```Python +import random +import re + +TEL_PATTERN = re.compile(r'1[3-9]\d{9}') + + +def check_tel(tel): + """检查手机号""" + return TEL_PATTERN.fullmatch(tel) is not None + + +def random_code(length=6): + """生成随机短信验证码""" + return ''.join(random.choices('0123456789', k=length)) +``` + +发送短信验证码的视图函数。 + +```Python +@api_view(('GET', )) +def get_mobilecode(request, tel): + """获取短信验证码""" + if check_tel(tel): + redis_cli = get_redis_connection() + if redis_cli.exists(f'vote:block-mobile:{tel}'): + data = {'code': 30001, 'message': '请不要在60秒内重复发送短信验证码'} + else: + code = random_code() + send_mobile_code(tel, code) + # 通过Redis阻止60秒内容重复发送短信验证码 + redis_cli.set(f'vote:block-mobile:{tel}', 'x', ex=60) + # 将验证码在Redis中保留10分钟(有效期10分钟) + redis_cli.set(f'vote2:valid-mobile:{tel}', code, ex=600) + data = {'code': 30000, 'message': '短信验证码已发送,请注意查收'} + else: + data = {'code': 30002, 'message': '请输入有效的手机号'} + return Response(data) +``` + +> **说明**:上面的代码利用Redis实现了两个额外的功能,一个是阻止用户60秒内重复发送短信验证码,一个是将用户的短信验证码保留10分钟,也就是说这个短信验证码的有效期只有10分钟,我们可以要求用户在注册时提供该验证码来验证用户手机号的真实性。 + +### 接入云存储服务 + +当我们提到**云存储**这个词的时候,通常是指把数据存放在由第三方提供的虚拟服务器环境下,简单的说就是将某些数据或资源通过第三平台托管。一般情况下,提供云存储服务的公司都运营着大型的数据中心,需要云存储服务的个人或组织通过向其购买或租赁存储空间来满足数据存储的需求。在开发Web应用时,可以将静态资源,尤其是用户上传的静态资源直接置于云存储服务中,云存储通常会提供对应的URL使得用户可以访问该静态资源。国内外比较有名的云存储服务(如:亚马逊的S3、阿里的OSS2等)一般都物美价廉,相比自己架设静态资源服务器,云存储的代价更小,而且一般的云存储平台都提供了CDN服务,用于加速对静态资源的访问,所以不管从哪个角度出发,使用云存储的方式管理Web应用的数据和静态资源都是非常好的选择,除非这些资源涉及到个人或商业隐私,否则就可以托管到云存储中。 + +下面我们以接入[七牛云](https://www.qiniu.com/)为例,讲解如何实现将用户上传的文件保存到七牛云存储。七牛云是国内知名的云计算及数据服务提供商,七牛云在海量文件存储、CDN、视频点播、互动直播以及大规模异构数据的智能分析与处理等领域都有自己的产品,而且非付费用户也可以免费接入,使用其提供的服务。下面是接入七牛云的流程: + +1. 注册账号,登录管理控制台。 + + ![](res/qiniu-manage-console.png) + +2. 选择左侧菜单中的对象存储。 + + ![](res/qiniu-storage-service.png) + +3. 在空间管理中选择新建空间(例如:myvote),如果提示空间名称已被占用,更换一个再尝试即可。注意,创建空间后会提示绑定自定义域名,如果暂时还没有自己的域名,可以使用七牛云提供的临时域名,但是临时域名会在30天后被回收,所以最好准备自己的域名(域名需要备案,不清楚如何操作的请自行查阅相关资料)。 + + ![](res/qiniu-storage-create.png) + +4. 在网页的右上角点击个人头像中的“密钥管理”,查看自己的密钥,稍后在代码中需要使用AK(AccessKey)和SK(SecretKey)两个密钥来认证用户身份。 + + ![](res/qiniu-secretkey-management.png) + +5. 点击网页上方菜单中的“文档”,进入到[七牛开发者中心](https://developer.qiniu.com/),选择导航菜单中的“SDK&工具”并点击“官方SDK”子菜单,找到Python(服务端)并点击“文档”查看官方文档。 + + ![](res/qiniu-document-python.png) + +接下来,只要安装官方文档提供的示例,就可以接入七牛云,使用七牛云提供的云存储以及其他服务。首先可以通过下面的命令安装七牛云的三方库。 + +```Bash +pip install qiniu +``` + +接下来可以通过`qiniu`模块中的`put_file`和`put_stream`两个函数实现文件上传,前者可以上传指定路径的文件,后者可以将内存中的二进制数据上传至七牛云,具体的代码如下所示。 + +```Python +import qiniu + +AUTH = qiniu.Auth('密钥管理中的AccessKey', '密钥管理中的SecretKey') +BUCKET_NAME = 'myvote' + + +def upload_file_to_qiniu(key, file_path): + """上传指定路径的文件到七牛云""" + token = AUTH.upload_token(BUCKET_NAME, key) + return qiniu.put_file(token, key, file_path) + + +def upload_stream_to_qiniu(key, stream, size): + """上传二进制数据流到七牛云""" + token = AUTH.upload_token(BUCKET_NAME, key) + return qiniu.put_stream(token, key, stream, None, size) +``` + +下面是一个文件上传的简单前端页。 + +```HTML + + + + + 上传文件 + + +
+
+ + +
+
+ + +``` + +> **说明**:前端如果使用表单实现文件上传,表单的method属性必须设置为post,enctype属性需要设置为multipart/form-data,表单中type属性为file的input标签,就是上传文件的文件选择器。 + +实现上传功能的视图函数如下所示。 + +```Python +from django.views.decorators.csrf import csrf_exempt + + +@csrf_exempt +def upload(request): + # 如果上传的文件小于2.5M,则photo对象的类型为InMemoryUploadedFile,文件在内存中 + # 如果上传的文件超过2.5M,则photo对象的类型为TemporaryUploadedFile,文件在临时路径下 + photo = request.FILES.get('photo') + _, ext = os.path.splitext(photo.name) + # 通过UUID和原来文件的扩展名生成独一无二的新的文件名 + filename = f'{uuid.uuid1().hex}{ext}' + # 对于内存中的文件,可以使用上面封装好的函数upload_stream_to_qiniu上传文件到七牛云 + # 如果文件保存在临时路径下,可以使用upload_file_to_qiniu实现文件上传 + upload_stream_to_qiniu(filename, photo.file, photo.size) + return redirect('/static/html/upload.html') +``` + +> **注意**:上面的视图函数使用了`csrf_exempt`装饰器,该装饰器能够让表单免除必须提供CSRF令牌的要求。此外,代码第11行使用了`uuid`模块的`uuid1`函数来生成全局唯一标识符。 + +运行项目尝试文件上传的功能,文件上传成功后,可以在七牛云“空间管理”中点击自己空间并进入“文件管理”界面,在这里可以看到我们刚才上传成功的文件,而且可以通过七牛云提供的域名获取该文件。 + +![](res/qiniu-file-management.png) + diff --git a/Day41-55/52.文件上传和富文本编辑.md b/Day41-55/52.文件上传和富文本编辑.md deleted file mode 100644 index 33d5f3f..0000000 --- a/Day41-55/52.文件上传和富文本编辑.md +++ /dev/null @@ -1,4 +0,0 @@ -## 文件上传和富文本编辑 - - - diff --git a/Day41-55/53.异步任务和定时任务.md b/Day41-55/53.异步任务和定时任务.md new file mode 100644 index 0000000..61e320b --- /dev/null +++ b/Day41-55/53.异步任务和定时任务.md @@ -0,0 +1,14 @@ +## 异步任务和定时任务 + +在Web应用中,如果一个请求执行了耗时间的操作或者该请求的执行时间无法确定,而且对于用户来说只需要知道服务器接收了他的请求,并不需要马上得到请求的执行结果,这样的操作我们就应该对其进行异步化处理。如果说**使用缓存是优化网站性能的第一要义**,那么将耗时间或执行时间不确定的任务**异步化则是网站性能优化的第二要义**,简单的说就是**能推迟做的事情都不要马上做**。 + +上一章节中讲到的发短信和上传文件到云存储为例,这两个操作前者属于时间不确定的操作(因为作为调用者,我们不能确定三方平台响应的时间),后者属于耗时间的操作(如果文件较大或者三方平台不稳定,都可能导致上传的时间较长),很显然,这两个操作都可以做异步化处理。 + +在Python项目中实现异步化处理可以使用多线程或借助三方库Celery来完成。 + +### 使用Celery实现异步化 + + + +### 使用多线程实现异步化 + diff --git a/Day41-55/53.短信和邮件.md b/Day41-55/53.短信和邮件.md deleted file mode 100644 index f6f3431..0000000 --- a/Day41-55/53.短信和邮件.md +++ /dev/null @@ -1,4 +0,0 @@ -## 短信和邮件 - - - diff --git a/Day41-55/54.单元测试.md b/Day41-55/54.单元测试.md new file mode 100644 index 0000000..d86a111 --- /dev/null +++ b/Day41-55/54.单元测试.md @@ -0,0 +1,4 @@ +## 单元测试 + +Python标准库中提供了名为`unittest` 的模块来支持我们对代码进行单元测试。所谓单元测试是指针对程序中最小的功能单元(在Python中指函数或类中的方法)进行的测试。 + diff --git a/Day41-55/54.异步任务和定时任务.md b/Day41-55/54.异步任务和定时任务.md deleted file mode 100644 index 8564288..0000000 --- a/Day41-55/54.异步任务和定时任务.md +++ /dev/null @@ -1,4 +0,0 @@ -## 异步任务和定时任务 - - - diff --git a/Day41-55/55.单元测试和项目上线.md b/Day41-55/55.单元测试和项目上线.md deleted file mode 100644 index 7793bc1..0000000 --- a/Day41-55/55.单元测试和项目上线.md +++ /dev/null @@ -1,3 +0,0 @@ -## 单元测试和项目上线 - - diff --git a/Day41-55/55.项目上线.md b/Day41-55/55.项目上线.md new file mode 100644 index 0000000..eac5b54 --- /dev/null +++ b/Day41-55/55.项目上线.md @@ -0,0 +1,4 @@ +## 项目上线 + +请各位读者移步到[《项目部署上线和性能调优》](../Day91-100/98.项目部署上线和性能调优.md)一文。 + diff --git a/Day41-55/code/shop/cart/__init__.py b/Day41-55/code/hellodjango/first/__init__.py similarity index 100% rename from Day41-55/code/shop/cart/__init__.py rename to Day41-55/code/hellodjango/first/__init__.py diff --git a/Day41-55/code/hellodjango/first/admin.py b/Day41-55/code/hellodjango/first/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/Day41-55/code/hellodjango/first/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Day41-55/code/hellodjango/first/apps.py b/Day41-55/code/hellodjango/first/apps.py new file mode 100644 index 0000000..5cd3644 --- /dev/null +++ b/Day41-55/code/hellodjango/first/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class FirstConfig(AppConfig): + name = 'first' diff --git a/Day41-55/code/shop/cart/migrations/__init__.py b/Day41-55/code/hellodjango/first/migrations/__init__.py similarity index 100% rename from Day41-55/code/shop/cart/migrations/__init__.py rename to Day41-55/code/hellodjango/first/migrations/__init__.py diff --git a/Day41-55/code/hellodjango/first/models.py b/Day41-55/code/hellodjango/first/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/Day41-55/code/hellodjango/first/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Day41-55/code/shop/cart/tests.py b/Day41-55/code/hellodjango/first/tests.py similarity index 100% rename from Day41-55/code/shop/cart/tests.py rename to Day41-55/code/hellodjango/first/tests.py diff --git a/Day41-55/code/hellodjango/first/views.py b/Day41-55/code/hellodjango/first/views.py new file mode 100644 index 0000000..7bb5d36 --- /dev/null +++ b/Day41-55/code/hellodjango/first/views.py @@ -0,0 +1,11 @@ +from random import sample + +from django.shortcuts import render + + +def show_index(request): + fruits = [ + 'Apple', 'Orange', 'Pitaya', 'Durian', 'Waxberry', 'Blueberry', + 'Grape', 'Peach', 'Pear', 'Banana', 'Watermelon', 'Mango' + ] + return render(request, 'index.html', {'fruits': sample(fruits, 3)}) diff --git a/Day41-55/code/shop_origin/cart/__init__.py b/Day41-55/code/hellodjango/hellodjango/__init__.py similarity index 100% rename from Day41-55/code/shop_origin/cart/__init__.py rename to Day41-55/code/hellodjango/hellodjango/__init__.py diff --git a/Day41-55/code/shop_origin/shop/settings.py b/Day41-55/code/hellodjango/hellodjango/settings.py similarity index 70% rename from Day41-55/code/shop_origin/shop/settings.py rename to Day41-55/code/hellodjango/hellodjango/settings.py index 337b099..9888496 100644 --- a/Day41-55/code/shop_origin/shop/settings.py +++ b/Day41-55/code/hellodjango/hellodjango/settings.py @@ -1,13 +1,13 @@ """ -Django settings for shop project. +Django settings for hellodjango project. -Generated by 'django-admin startproject' using Django 2.0.5. +Generated by 'django-admin startproject' using Django 2.2.13. For more information on this file, see -https://docs.djangoproject.com/en/2.0/topics/settings/ +https://docs.djangoproject.com/en/2.2/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.0/ref/settings/ +https://docs.djangoproject.com/en/2.2/ref/settings/ """ import os @@ -17,10 +17,10 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '+gqc54!5+uhvc^o0)fjvihmg&5uu^u+#s5m*fc+e+@bw*(+!w*' +SECRET_KEY = 'x)q$(0m0^ttqii@^zn^9bdbh&%l$)wzjm=nv&_y+^y9e!37=-z' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -37,7 +37,6 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'cart', ] MIDDLEWARE = [ @@ -50,13 +49,12 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'shop.urls' +ROOT_URLCONF = 'hellodjango.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')] - , + 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -69,26 +67,22 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = 'shop.wsgi.application' +WSGI_APPLICATION = 'hellodjango.wsgi.application' # Database -# https://docs.djangoproject.com/en/2.0/ref/settings/#databases +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'Shop', - 'HOST': 'localhost', - 'PORT': 3306, - 'USER': 'root', - 'PASSWORD': '123456', + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation -# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -107,11 +101,11 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/2.0/topics/i18n/ +# https://docs.djangoproject.com/en/2.2/topics/i18n/ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'Asia/Chongqing' +TIME_ZONE = 'UTC' USE_I18N = True @@ -121,6 +115,6 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.0/howto/static-files/ -STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + STATIC_URL = '/static/' diff --git a/Day41-55/code/shop_origin/shop/urls.py b/Day41-55/code/hellodjango/hellodjango/urls.py similarity index 74% rename from Day41-55/code/shop_origin/shop/urls.py rename to Day41-55/code/hellodjango/hellodjango/urls.py index fb34b04..a5f26e5 100644 --- a/Day41-55/code/shop_origin/shop/urls.py +++ b/Day41-55/code/hellodjango/hellodjango/urls.py @@ -1,7 +1,7 @@ -"""shop URL Configuration +"""hellodjango URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.0/topics/http/urls/ + https://docs.djangoproject.com/en/2.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views @@ -16,11 +16,9 @@ Including another URLconf from django.contrib import admin from django.urls import path -from cart import views +from first.views import show_index urlpatterns = [ - path('', views.index), - path('show_cart', views.show_cart), - path('add_to_cart/', views.add_to_cart), path('admin/', admin.site.urls), + path('hello/', show_index), ] diff --git a/Day41-55/code/shop/shop/wsgi.py b/Day41-55/code/hellodjango/hellodjango/wsgi.py similarity index 57% rename from Day41-55/code/shop/shop/wsgi.py rename to Day41-55/code/hellodjango/hellodjango/wsgi.py index 1aa46d9..0d73723 100644 --- a/Day41-55/code/shop/shop/wsgi.py +++ b/Day41-55/code/hellodjango/hellodjango/wsgi.py @@ -1,16 +1,16 @@ """ -WSGI config for shop project. +WSGI config for hellodjango project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings") +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hellodjango.settings') application = get_wsgi_application() diff --git a/Day41-55/code/shop_origin/manage.py b/Day41-55/code/hellodjango/manage.py old mode 100644 new mode 100755 similarity index 69% rename from Day41-55/code/shop_origin/manage.py rename to Day41-55/code/hellodjango/manage.py index 175f50a..15272c0 --- a/Day41-55/code/shop_origin/manage.py +++ b/Day41-55/code/hellodjango/manage.py @@ -1,9 +1,11 @@ #!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" import os import sys -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings") + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hellodjango.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -13,3 +15,7 @@ if __name__ == "__main__": "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/Day41-55/code/hellodjango/templates/index.html b/Day41-55/code/hellodjango/templates/index.html new file mode 100644 index 0000000..545cb2d --- /dev/null +++ b/Day41-55/code/hellodjango/templates/index.html @@ -0,0 +1,21 @@ + + + + + 首页 + + + +

今天推荐的水果是:

+
+
    + {% for fruit in fruits %} +
  • {{ fruit }}
  • + {% endfor %} +
+ + \ No newline at end of file diff --git a/Day41-55/code/shop/cart/admin.py b/Day41-55/code/shop/cart/admin.py deleted file mode 100644 index cc89c6c..0000000 --- a/Day41-55/code/shop/cart/admin.py +++ /dev/null @@ -1,12 +0,0 @@ -from django.contrib import admin - -from cart.models import Goods - - -class GoodsAdmin(admin.ModelAdmin): - - list_display = ('id', 'name', 'price', 'image') - search_fields = ('name', ) - - -admin.site.register(Goods, GoodsAdmin) diff --git a/Day41-55/code/shop/cart/apps.py b/Day41-55/code/shop/cart/apps.py deleted file mode 100644 index 7cc6ec1..0000000 --- a/Day41-55/code/shop/cart/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class CartConfig(AppConfig): - name = 'cart' diff --git a/Day41-55/code/shop/cart/migrations/0001_initial.py b/Day41-55/code/shop/cart/migrations/0001_initial.py deleted file mode 100644 index 0419831..0000000 --- a/Day41-55/code/shop/cart/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.0.5 on 2018-05-25 06:28 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Goods', - fields=[ - ('id', models.AutoField(db_column='gid', primary_key=True, serialize=False)), - ('name', models.CharField(db_column='gname', max_length=50)), - ('price', models.DecimalField(db_column='gprice', decimal_places=2, max_digits=10)), - ('image', models.CharField(db_column='gimage', max_length=255)), - ], - options={ - 'db_table': 'tb_goods', - 'ordering': ('id',), - }, - ), - ] diff --git a/Day41-55/code/shop/cart/models.py b/Day41-55/code/shop/cart/models.py deleted file mode 100644 index e65ff97..0000000 --- a/Day41-55/code/shop/cart/models.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.db import models - - -class Goods(models.Model): - """商品模型类""" - - id = models.AutoField(primary_key=True, db_column='gid') - name = models.CharField(max_length=50, db_column='gname') - price = models.DecimalField(max_digits=10, decimal_places=2, db_column='gprice') - image = models.CharField(max_length=255, db_column='gimage') - - class Meta: - - db_table = 'tb_goods' - ordering = ('id', ) diff --git a/Day41-55/code/shop/cart/views.py b/Day41-55/code/shop/cart/views.py deleted file mode 100644 index dfbf6ee..0000000 --- a/Day41-55/code/shop/cart/views.py +++ /dev/null @@ -1,77 +0,0 @@ -from django.core import serializers -from django.shortcuts import render, redirect - -from cart.models import Goods - - -def index(request): - goods_list = list(Goods.objects.all()) - return render(request, 'goods.html', {'goods_list': goods_list}) - - -class CartItem(object): - """购物车中的商品项""" - - def __init__(self, goods, amount=1): - self.goods = goods - self.amount = amount - - @property - def total(self): - return self.goods.price * self.amount - - -class ShoppingCart(object): - """购物车""" - - def __init__(self): - self.items = {} - self.index = 0 - - def add_item(self, item): - if item.goods.id in self.items: - self.items[item.goods.id].amount += item.amount - else: - self.items[item.goods.id] = item - - def remove_item(self, id): - if id in self.items: - self.items.remove(id) - - def clear_all_items(self): - self.items.clear() - - @property - def cart_items(self): - return self.items.values() - - @property - def total(self): - val = 0 - for item in self.items.values(): - val += item.total - return val - - -def add_to_cart(request, id): - goods = Goods.objects.get(pk=id) - # 通过request对象的session属性可以获取到session - # session相当于是服务器端用来保存用户数据的一个字典 - # session利用了Cookie保存sessionid - # 通过sessionid就可以获取与某个用户对应的会话(也就是用户数据) - # 如果在浏览器中清除了Cookie那么也就清除了sessionid - # 再次访问服务器时服务器会重新分配新的sessionid这也就意味着之前的用户数据无法找回 - # 默认情况下Django的session被设定为持久会话而非浏览器续存期会话 - # 通过SESSION_EXPIRE_AT_BROWSER_CLOSE和SESSION_COOKIE_AGE参数可以修改默认设定 - # Django中的session是进行了持久化处理的因此需要设定session的序列化方式 - # 1.6版开始Django默认的session序列化器是JsonSerializer - # 可以通过SESSION_SERIALIZER来设定其他的序列化器(例如PickleSerializer) - cart = request.session.get('cart', ShoppingCart()) - cart.add_item(CartItem(goods)) - request.session['cart'] = cart - return redirect('/') - - -def show_cart(request): - cart = serializers.deserialize(request.session.get('cart')) - return render(request, 'cart.html', {'cart': cart}) diff --git a/Day41-55/code/shop/manage.py b/Day41-55/code/shop/manage.py deleted file mode 100644 index 175f50a..0000000 --- a/Day41-55/code/shop/manage.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -if __name__ == "__main__": - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings") - try: - from django.core.management import execute_from_command_line - except ImportError as exc: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) from exc - execute_from_command_line(sys.argv) diff --git a/Day41-55/code/shop/shop/__init__.py b/Day41-55/code/shop/shop/__init__.py deleted file mode 100644 index 9c0f756..0000000 --- a/Day41-55/code/shop/shop/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import pymysql - -pymysql.install_as_MySQLdb() diff --git a/Day41-55/code/shop/shop/settings.py b/Day41-55/code/shop/shop/settings.py deleted file mode 100644 index f90e37a..0000000 --- a/Day41-55/code/shop/shop/settings.py +++ /dev/null @@ -1,129 +0,0 @@ -""" -Django settings for shop project. - -Generated by 'django-admin startproject' using Django 2.0.5. - -For more information on this file, see -https://docs.djangoproject.com/en/2.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.0/ref/settings/ -""" - -import os - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '3(n^av%_kt*^2zhz0!iwkxv6_wp^ed7-dpow*vqr7ck0_6=9^e' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'cart.apps.CartConfig', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'shop.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')] - , - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'shop.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/2.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'shop', - 'HOST': 'localhost', - 'PORT': 3306, - 'USER': 'root', - 'PASSWORD': '123456', - } -} - - -# Password validation -# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - -# SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' - -# Internationalization -# https://docs.djangoproject.com/en/2.0/topics/i18n/ - -LANGUAGE_CODE = 'zh-hans' - -TIME_ZONE = 'Asia/Chongqing' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.0/howto/static-files/ - -STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),] - -STATIC_URL = '/static/' diff --git a/Day41-55/code/shop/shop/urls.py b/Day41-55/code/shop/shop/urls.py deleted file mode 100644 index c308ec0..0000000 --- a/Day41-55/code/shop/shop/urls.py +++ /dev/null @@ -1,26 +0,0 @@ -"""shop URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path - -from cart import views - -urlpatterns = [ - path('', views.index), - path('add_to_cart/', views.add_to_cart), - path('show_cart', views.show_cart), - path('admin/', admin.site.urls), -] diff --git a/Day41-55/code/shop/static/images/dolbee.jpg b/Day41-55/code/shop/static/images/dolbee.jpg deleted file mode 100644 index 03e4a92..0000000 Binary files a/Day41-55/code/shop/static/images/dolbee.jpg and /dev/null differ diff --git a/Day41-55/code/shop/static/images/lay.jpg b/Day41-55/code/shop/static/images/lay.jpg deleted file mode 100644 index 254a4cc..0000000 Binary files a/Day41-55/code/shop/static/images/lay.jpg and /dev/null differ diff --git a/Day41-55/code/shop/static/images/noodle.jpg b/Day41-55/code/shop/static/images/noodle.jpg deleted file mode 100644 index 1907c18..0000000 Binary files a/Day41-55/code/shop/static/images/noodle.jpg and /dev/null differ diff --git a/Day41-55/code/shop/static/images/oil.jpg b/Day41-55/code/shop/static/images/oil.jpg deleted file mode 100644 index bcb3f7a..0000000 Binary files a/Day41-55/code/shop/static/images/oil.jpg and /dev/null differ diff --git a/Day41-55/code/shop/static/images/wang.jpg b/Day41-55/code/shop/static/images/wang.jpg deleted file mode 100644 index 8b94ca2..0000000 Binary files a/Day41-55/code/shop/static/images/wang.jpg and /dev/null differ diff --git a/Day41-55/code/shop/static/images/wine.jpg b/Day41-55/code/shop/static/images/wine.jpg deleted file mode 100644 index 96e1a56..0000000 Binary files a/Day41-55/code/shop/static/images/wine.jpg and /dev/null differ diff --git a/Day41-55/code/shop/templates/cart.html b/Day41-55/code/shop/templates/cart.html deleted file mode 100644 index 7b67433..0000000 --- a/Day41-55/code/shop/templates/cart.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -
-

购物车列表

-
-
-
- 返回 -
- {% if cart %} - - - - - - - - - {% for item in cart %} - - - - - - - - {% endfor %} - - - -
商品名称商品单价商品数量商品总价操作
{{ item.goods.name }}¥{{ item.goods.price }}{{ item.amount }}¥{{ item.total }} - 删除 -
¥{{ cart.total }}元
- 清空购物车 - {% else %} -

购物车中暂时没有商品!

- {% endif %} - - \ No newline at end of file diff --git a/Day41-55/code/shop/templates/goods.html b/Day41-55/code/shop/templates/goods.html deleted file mode 100644 index 9e3c9b7..0000000 --- a/Day41-55/code/shop/templates/goods.html +++ /dev/null @@ -1,46 +0,0 @@ - -{% load staticfiles %} - - - - - - -
-

商品列表

-
-
- - - - - - - - - {% for goods in goods_list %} - - - - - - - {% endfor %} -
商品名称商品价格商品图片操作
{{ goods.name }}¥{{ goods.price }} - {{ goods.name }} - - 加入购物车 -
- - \ No newline at end of file diff --git a/Day41-55/code/shop_origin/cart/admin.py b/Day41-55/code/shop_origin/cart/admin.py deleted file mode 100644 index 33eb176..0000000 --- a/Day41-55/code/shop_origin/cart/admin.py +++ /dev/null @@ -1,11 +0,0 @@ -from django.contrib import admin - -from cart.models import Goods - - -class GoodsAdmin(admin.ModelAdmin): - - list_display = ('id', 'name', 'price', 'image') - - -admin.site.register(Goods, GoodsAdmin) diff --git a/Day41-55/code/shop_origin/cart/apps.py b/Day41-55/code/shop_origin/cart/apps.py deleted file mode 100644 index 7cc6ec1..0000000 --- a/Day41-55/code/shop_origin/cart/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class CartConfig(AppConfig): - name = 'cart' diff --git a/Day41-55/code/shop_origin/cart/migrations/0001_initial.py b/Day41-55/code/shop_origin/cart/migrations/0001_initial.py deleted file mode 100644 index a3c1f87..0000000 --- a/Day41-55/code/shop_origin/cart/migrations/0001_initial.py +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by Django 2.0.5 on 2018-05-25 05:11 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Goods', - fields=[ - ('id', models.AutoField(db_column='gid', primary_key=True, serialize=False)), - ('name', models.CharField(db_column='gname', max_length=50)), - ('price', models.DecimalField(db_column='gprice', decimal_places=2, max_digits=10)), - ('image', models.CharField(db_column='gimage', max_length=255)), - ], - options={ - 'db_table': 'tb_goods', - 'ordering': ('id',), - }, - ), - ] diff --git a/Day41-55/code/shop_origin/cart/models.py b/Day41-55/code/shop_origin/cart/models.py deleted file mode 100644 index 5f6a9b8..0000000 --- a/Day41-55/code/shop_origin/cart/models.py +++ /dev/null @@ -1,13 +0,0 @@ -from django.db import models - - -class Goods(models.Model): - - id = models.AutoField(primary_key=True, db_column='gid') - name = models.CharField(max_length=50, db_column='gname') - price = models.DecimalField(max_digits=10, decimal_places=2, db_column='gprice') - image = models.CharField(max_length=255, db_column='gimage') - - class Meta: - db_table = 'tb_goods' - ordering = ('id',) diff --git a/Day41-55/code/shop_origin/cart/tests.py b/Day41-55/code/shop_origin/cart/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/Day41-55/code/shop_origin/cart/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/Day41-55/code/shop_origin/cart/views.py b/Day41-55/code/shop_origin/cart/views.py deleted file mode 100644 index a1c3378..0000000 --- a/Day41-55/code/shop_origin/cart/views.py +++ /dev/null @@ -1,16 +0,0 @@ -from django.shortcuts import render - -from cart.models import Goods - - -def index(request): - goods_list = list(Goods.objects.all()) - return render(request, 'goods.html', {'goods_list': goods_list}) - - -def show_cart(request): - return render(request, 'cart.html') - - -def add_to_cart(request, no): - pass diff --git a/Day41-55/code/shop_origin/shop/__init__.py b/Day41-55/code/shop_origin/shop/__init__.py deleted file mode 100644 index aa60bed..0000000 --- a/Day41-55/code/shop_origin/shop/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import pymysql - -pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/Day41-55/code/shop_origin/shop/wsgi.py b/Day41-55/code/shop_origin/shop/wsgi.py deleted file mode 100644 index 1aa46d9..0000000 --- a/Day41-55/code/shop_origin/shop/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for shop project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shop.settings") - -application = get_wsgi_application() diff --git a/Day41-55/code/shop_origin/shop_create_sql.sql b/Day41-55/code/shop_origin/shop_create_sql.sql deleted file mode 100644 index f60ee27..0000000 --- a/Day41-55/code/shop_origin/shop_create_sql.sql +++ /dev/null @@ -1,7 +0,0 @@ -insert into tb_goods values -(default, '乐事(Lay’s)无限薯片', 8.2, 'images/lay.jpg'), -(default, '旺旺 仙贝 加量装 540g', 18.5, 'images/wang.jpg'), -(default, '多儿比(Dolbee)黄桃水果罐头', 6.8, 'images/dolbee.jpg'), -(default, '王致和 精制料酒 500ml', 7.9, 'images/wine.jpg'), -(default, '陈克明 面条 鸡蛋龙须挂面', 1.0, 'images/noodle.jpg'), -(default, '鲁花 菜籽油 4L', 69.9, 'images/oil.jpg'); \ No newline at end of file diff --git a/Day41-55/code/shop_origin/static/images/dolbee.jpg b/Day41-55/code/shop_origin/static/images/dolbee.jpg deleted file mode 100644 index 03e4a92..0000000 Binary files a/Day41-55/code/shop_origin/static/images/dolbee.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/static/images/lay.jpg b/Day41-55/code/shop_origin/static/images/lay.jpg deleted file mode 100644 index 254a4cc..0000000 Binary files a/Day41-55/code/shop_origin/static/images/lay.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/static/images/noodle.jpg b/Day41-55/code/shop_origin/static/images/noodle.jpg deleted file mode 100644 index 1907c18..0000000 Binary files a/Day41-55/code/shop_origin/static/images/noodle.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/static/images/oil.jpg b/Day41-55/code/shop_origin/static/images/oil.jpg deleted file mode 100644 index bcb3f7a..0000000 Binary files a/Day41-55/code/shop_origin/static/images/oil.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/static/images/wang.jpg b/Day41-55/code/shop_origin/static/images/wang.jpg deleted file mode 100644 index 8b94ca2..0000000 Binary files a/Day41-55/code/shop_origin/static/images/wang.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/static/images/wine.jpg b/Day41-55/code/shop_origin/static/images/wine.jpg deleted file mode 100644 index 96e1a56..0000000 Binary files a/Day41-55/code/shop_origin/static/images/wine.jpg and /dev/null differ diff --git a/Day41-55/code/shop_origin/templates/cart.html b/Day41-55/code/shop_origin/templates/cart.html deleted file mode 100644 index 2291b9c..0000000 --- a/Day41-55/code/shop_origin/templates/cart.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -
-

购物车列表

-
-
-
- 返回 -
- {% if cart_items %} - - - - - - - - - {% for item in cart_items %} - - - - - - - - {% endfor %} - - - -
商品名称商品单价商品数量商品总价操作
{{ item.name }}¥{{ item.unit_price }}{{ item.amount }}¥{{ item.total_price }} - 删除 -
¥{{ cart.total }}元
- 清空购物车 - {% else %} -

购物车中暂时没有商品!

- {% endif %} - - \ No newline at end of file diff --git a/Day41-55/code/shop_origin/templates/goods.html b/Day41-55/code/shop_origin/templates/goods.html deleted file mode 100644 index 9e3c9b7..0000000 --- a/Day41-55/code/shop_origin/templates/goods.html +++ /dev/null @@ -1,46 +0,0 @@ - -{% load staticfiles %} - - - - - - -
-

商品列表

-
-
- - - - - - - - - {% for goods in goods_list %} - - - - - - - {% endfor %} -
商品名称商品价格商品图片操作
{{ goods.name }}¥{{ goods.price }} - {{ goods.name }} - - 加入购物车 -
- - \ No newline at end of file diff --git a/Day41-55/res/CSRF.png b/Day41-55/res/CSRF.png index 6e87482..3108524 100644 Binary files a/Day41-55/res/CSRF.png and b/Day41-55/res/CSRF.png differ diff --git a/Day41-55/res/Django-Flowchart.png b/Day41-55/res/Django-Flowchart.png index ef96033..2ed0cfe 100644 Binary files a/Day41-55/res/Django-Flowchart.png and b/Day41-55/res/Django-Flowchart.png differ diff --git a/Day41-55/res/Django-MTV.png b/Day41-55/res/Django-MTV.png index 76f330e..b075e93 100644 Binary files a/Day41-55/res/Django-MTV.png and b/Day41-55/res/Django-MTV.png differ diff --git a/Day41-55/res/admin-login.png b/Day41-55/res/admin-login.png deleted file mode 100644 index 15ea232..0000000 Binary files a/Day41-55/res/admin-login.png and /dev/null differ diff --git a/Day41-55/res/admin-model-create.png b/Day41-55/res/admin-model-create.png deleted file mode 100644 index 5d07891..0000000 Binary files a/Day41-55/res/admin-model-create.png and /dev/null differ diff --git a/Day41-55/res/admin-model-delete-and-update.png b/Day41-55/res/admin-model-delete-and-update.png deleted file mode 100644 index 87d709c..0000000 Binary files a/Day41-55/res/admin-model-delete-and-update.png and /dev/null differ diff --git a/Day41-55/res/admin-model-depts.png b/Day41-55/res/admin-model-depts.png deleted file mode 100644 index 7214544..0000000 Binary files a/Day41-55/res/admin-model-depts.png and /dev/null differ diff --git a/Day41-55/res/admin-model-emps-modified.png b/Day41-55/res/admin-model-emps-modified.png deleted file mode 100644 index 27c6205..0000000 Binary files a/Day41-55/res/admin-model-emps-modified.png and /dev/null differ diff --git a/Day41-55/res/admin-model-emps.png b/Day41-55/res/admin-model-emps.png deleted file mode 100644 index b9b7953..0000000 Binary files a/Day41-55/res/admin-model-emps.png and /dev/null differ diff --git a/Day41-55/res/admin-model-read.png b/Day41-55/res/admin-model-read.png deleted file mode 100644 index 135437b..0000000 Binary files a/Day41-55/res/admin-model-read.png and /dev/null differ diff --git a/Day41-55/res/admin-model.png b/Day41-55/res/admin-model.png deleted file mode 100644 index 12fa9e0..0000000 Binary files a/Day41-55/res/admin-model.png and /dev/null differ diff --git a/Day41-55/res/admin-welcome.png b/Day41-55/res/admin-welcome.png deleted file mode 100644 index 2371ffe..0000000 Binary files a/Day41-55/res/admin-welcome.png and /dev/null differ diff --git a/Day41-55/res/asynchronous-web-request.png b/Day41-55/res/asynchronous-web-request.png new file mode 100644 index 0000000..41bf070 Binary files /dev/null and b/Day41-55/res/asynchronous-web-request.png differ diff --git a/Day41-55/res/captcha.png b/Day41-55/res/captcha.png index 59b8065..a0a5ce5 100644 Binary files a/Day41-55/res/captcha.png and b/Day41-55/res/captcha.png differ diff --git a/Day41-55/res/cookie_xstorage_indexeddb.png b/Day41-55/res/cookie_xstorage_indexeddb.png index a08c257..e21643f 100644 Binary files a/Day41-55/res/cookie_xstorage_indexeddb.png and b/Day41-55/res/cookie_xstorage_indexeddb.png differ diff --git a/Day41-55/res/csrf-simple.png b/Day41-55/res/csrf-simple.png new file mode 100644 index 0000000..9ffae31 Binary files /dev/null and b/Day41-55/res/csrf-simple.png differ diff --git a/Day41-55/res/debug-toolbar.png b/Day41-55/res/debug-toolbar.png new file mode 100644 index 0000000..ffc1b15 Binary files /dev/null and b/Day41-55/res/debug-toolbar.png differ diff --git a/Day41-55/res/django-admin-add-model.png b/Day41-55/res/django-admin-add-model.png new file mode 100644 index 0000000..a38f2f2 Binary files /dev/null and b/Day41-55/res/django-admin-add-model.png differ diff --git a/Day41-55/res/django-admin-apps.png b/Day41-55/res/django-admin-apps.png new file mode 100644 index 0000000..26f6614 Binary files /dev/null and b/Day41-55/res/django-admin-apps.png differ diff --git a/Day41-55/res/django-admin-delete-update-model.png b/Day41-55/res/django-admin-delete-update-model.png new file mode 100644 index 0000000..ee5605a Binary files /dev/null and b/Day41-55/res/django-admin-delete-update-model.png differ diff --git a/Day41-55/res/django-admin-login.png b/Day41-55/res/django-admin-login.png new file mode 100644 index 0000000..7a172d7 Binary files /dev/null and b/Day41-55/res/django-admin-login.png differ diff --git a/Day41-55/res/django-admin-models.png b/Day41-55/res/django-admin-models.png new file mode 100644 index 0000000..9ff5486 Binary files /dev/null and b/Day41-55/res/django-admin-models.png differ diff --git a/Day41-55/res/django-admin-view-models-subject.png b/Day41-55/res/django-admin-view-models-subject.png new file mode 100644 index 0000000..acbaf9d Binary files /dev/null and b/Day41-55/res/django-admin-view-models-subject.png differ diff --git a/Day41-55/res/django-admin-view-models-teacher.png b/Day41-55/res/django-admin-view-models-teacher.png new file mode 100644 index 0000000..3036e41 Binary files /dev/null and b/Day41-55/res/django-admin-view-models-teacher.png differ diff --git a/Day41-55/res/django-admin-view-models.png b/Day41-55/res/django-admin-view-models.png new file mode 100644 index 0000000..e27dce3 Binary files /dev/null and b/Day41-55/res/django-admin-view-models.png differ diff --git a/Day41-55/res/django-index-1.png b/Day41-55/res/django-index-1.png index df4ba60..65ccc75 100644 Binary files a/Day41-55/res/django-index-1.png and b/Day41-55/res/django-index-1.png differ diff --git a/Day41-55/res/django-index-2.png b/Day41-55/res/django-index-2.png index 6b5edb9..7c19786 100644 Binary files a/Day41-55/res/django-index-2.png and b/Day41-55/res/django-index-2.png differ diff --git a/Day41-55/res/django-middleware.png b/Day41-55/res/django-middleware.png new file mode 100644 index 0000000..ab77a5d Binary files /dev/null and b/Day41-55/res/django-middleware.png differ diff --git a/Day41-55/res/drf-app.png b/Day41-55/res/drf-app.png new file mode 100644 index 0000000..c60ed38 Binary files /dev/null and b/Day41-55/res/drf-app.png differ diff --git a/Day41-55/res/echarts_bar_graph.png b/Day41-55/res/echarts_bar_graph.png index a77571f..d2f40ea 100644 Binary files a/Day41-55/res/echarts_bar_graph.png and b/Day41-55/res/echarts_bar_graph.png differ diff --git a/Day41-55/res/er-graph.png b/Day41-55/res/er-graph.png deleted file mode 100644 index 9072a9d..0000000 Binary files a/Day41-55/res/er-graph.png and /dev/null differ diff --git a/Day41-55/res/http-request.png b/Day41-55/res/http-request.png index aca9287..67d0fb6 100644 Binary files a/Day41-55/res/http-request.png and b/Day41-55/res/http-request.png differ diff --git a/Day41-55/res/http-response.png b/Day41-55/res/http-response.png index f2b8ae3..0de1144 100644 Binary files a/Day41-55/res/http-response.png and b/Day41-55/res/http-response.png differ diff --git a/Day41-55/res/json-web-token.png b/Day41-55/res/json-web-token.png new file mode 100644 index 0000000..9af29ba Binary files /dev/null and b/Day41-55/res/json-web-token.png differ diff --git a/Day41-55/res/luosimao-pay-onlinebuy.png b/Day41-55/res/luosimao-pay-onlinebuy.png new file mode 100644 index 0000000..a8c69b9 Binary files /dev/null and b/Day41-55/res/luosimao-pay-onlinebuy.png differ diff --git a/Day41-55/res/luosimao-sms-apikey.png b/Day41-55/res/luosimao-sms-apikey.png new file mode 100644 index 0000000..251ba93 Binary files /dev/null and b/Day41-55/res/luosimao-sms-apikey.png differ diff --git a/Day41-55/res/luosimao-sms-signature.png b/Day41-55/res/luosimao-sms-signature.png new file mode 100644 index 0000000..7fd2617 Binary files /dev/null and b/Day41-55/res/luosimao-sms-signature.png differ diff --git a/Day41-55/res/luosimao-sms-whitelist.png b/Day41-55/res/luosimao-sms-whitelist.png new file mode 100644 index 0000000..6f67168 Binary files /dev/null and b/Day41-55/res/luosimao-sms-whitelist.png differ diff --git a/Day41-55/res/mvc.png b/Day41-55/res/mvc.png index 7ba14ba..0481ccb 100644 Binary files a/Day41-55/res/mvc.png and b/Day41-55/res/mvc.png differ diff --git a/Day41-55/res/pycharm-django-project.png b/Day41-55/res/pycharm-django-project.png new file mode 100644 index 0000000..233b350 Binary files /dev/null and b/Day41-55/res/pycharm-django-project.png differ diff --git a/Day41-55/res/pycharm-django-server.png b/Day41-55/res/pycharm-django-server.png new file mode 100644 index 0000000..a6d0fae Binary files /dev/null and b/Day41-55/res/pycharm-django-server.png differ diff --git a/Day41-55/res/pycharm-django-static.png b/Day41-55/res/pycharm-django-static.png new file mode 100644 index 0000000..a96a646 Binary files /dev/null and b/Day41-55/res/pycharm-django-static.png differ diff --git a/Day41-55/res/pycharm-django-template.png b/Day41-55/res/pycharm-django-template.png new file mode 100644 index 0000000..7242df8 Binary files /dev/null and b/Day41-55/res/pycharm-django-template.png differ diff --git a/Day41-55/res/pycharm-django-virtual-environment.png b/Day41-55/res/pycharm-django-virtual-environment.png new file mode 100644 index 0000000..2c4c8f7 Binary files /dev/null and b/Day41-55/res/pycharm-django-virtual-environment.png differ diff --git a/Day41-55/res/pycharm-install-django.png b/Day41-55/res/pycharm-install-django.png new file mode 100644 index 0000000..11d1eaf Binary files /dev/null and b/Day41-55/res/pycharm-install-django.png differ diff --git a/Day41-55/res/pycharm-python-manage.png b/Day41-55/res/pycharm-python-manage.png new file mode 100644 index 0000000..ed1b614 Binary files /dev/null and b/Day41-55/res/pycharm-python-manage.png differ diff --git a/Day41-55/res/pycharm-vote-project.png b/Day41-55/res/pycharm-vote-project.png new file mode 100644 index 0000000..1a6eaf4 Binary files /dev/null and b/Day41-55/res/pycharm-vote-project.png differ diff --git a/Day41-55/res/qiniu-document-python.png b/Day41-55/res/qiniu-document-python.png new file mode 100644 index 0000000..1b2853e Binary files /dev/null and b/Day41-55/res/qiniu-document-python.png differ diff --git a/Day41-55/res/qiniu-file-management.png b/Day41-55/res/qiniu-file-management.png new file mode 100644 index 0000000..a56244a Binary files /dev/null and b/Day41-55/res/qiniu-file-management.png differ diff --git a/Day41-55/res/qiniu-manage-console.png b/Day41-55/res/qiniu-manage-console.png new file mode 100644 index 0000000..ef69a3e Binary files /dev/null and b/Day41-55/res/qiniu-manage-console.png differ diff --git a/Day41-55/res/qiniu-secretkey-management.png b/Day41-55/res/qiniu-secretkey-management.png new file mode 100644 index 0000000..dc6c006 Binary files /dev/null and b/Day41-55/res/qiniu-secretkey-management.png differ diff --git a/Day41-55/res/qiniu-storage-create.png b/Day41-55/res/qiniu-storage-create.png new file mode 100644 index 0000000..6ec4205 Binary files /dev/null and b/Day41-55/res/qiniu-storage-create.png differ diff --git a/Day41-55/res/qiniu-storage-service.png b/Day41-55/res/qiniu-storage-service.png new file mode 100644 index 0000000..fbf4c8c Binary files /dev/null and b/Day41-55/res/qiniu-storage-service.png differ diff --git a/Day41-55/res/redis-cache-service.png b/Day41-55/res/redis-cache-service.png new file mode 100644 index 0000000..06a618e Binary files /dev/null and b/Day41-55/res/redis-cache-service.png differ diff --git a/Day41-55/res/sessionid_from_cookie.png b/Day41-55/res/sessionid_from_cookie.png index 6dfc76e..23b40aa 100644 Binary files a/Day41-55/res/sessionid_from_cookie.png and b/Day41-55/res/sessionid_from_cookie.png differ diff --git a/Day41-55/res/show-depts.png b/Day41-55/res/show-depts.png deleted file mode 100644 index ceaecc8..0000000 Binary files a/Day41-55/res/show-depts.png and /dev/null differ diff --git a/Day41-55/res/show_subjects.png b/Day41-55/res/show_subjects.png deleted file mode 100644 index 9e7612d..0000000 Binary files a/Day41-55/res/show_subjects.png and /dev/null differ diff --git a/Day41-55/res/show_teachers.png b/Day41-55/res/show_teachers.png deleted file mode 100644 index 031ac57..0000000 Binary files a/Day41-55/res/show_teachers.png and /dev/null differ diff --git a/Day41-55/res/synchronous-web-request.png b/Day41-55/res/synchronous-web-request.png new file mode 100644 index 0000000..1f5661b Binary files /dev/null and b/Day41-55/res/synchronous-web-request.png differ diff --git a/Day41-55/res/web-application.png b/Day41-55/res/web-application.png index 89d2dec..5a18949 100644 Binary files a/Day41-55/res/web-application.png and b/Day41-55/res/web-application.png differ diff --git a/Day56-60/56-60.用FastAPI开发数据接口.md b/Day56-60/56-60.用FastAPI开发数据接口.md new file mode 100644 index 0000000..bca9652 --- /dev/null +++ b/Day56-60/56-60.用FastAPI开发数据接口.md @@ -0,0 +1,2 @@ +## 用FastAPI开发数据接口 + diff --git a/Day56-60/56.Flask入门.md b/Day56-60/56.Flask入门.md deleted file mode 100644 index 5c4d659..0000000 --- a/Day56-60/56.Flask入门.md +++ /dev/null @@ -1,2 +0,0 @@ -## Flask入门 - diff --git a/Day56-60/57.模板的使用.md b/Day56-60/57.模板的使用.md deleted file mode 100644 index 3344e2e..0000000 --- a/Day56-60/57.模板的使用.md +++ /dev/null @@ -1,2 +0,0 @@ -## 模板的使用 - diff --git a/Day56-60/58.表单的处理.md b/Day56-60/58.表单的处理.md deleted file mode 100644 index 895e910..0000000 --- a/Day56-60/58.表单的处理.md +++ /dev/null @@ -1,2 +0,0 @@ -## 表单的处理 - diff --git a/Day56-60/59.数据库操作.md b/Day56-60/59.数据库操作.md deleted file mode 100644 index d8a6a1b..0000000 --- a/Day56-60/59.数据库操作.md +++ /dev/null @@ -1,2 +0,0 @@ -## 数据库操作 - diff --git a/Day56-60/60.项目实战.md b/Day56-60/60.项目实战.md deleted file mode 100644 index dbbae84..0000000 --- a/Day56-60/60.项目实战.md +++ /dev/null @@ -1,2 +0,0 @@ -## 项目实战 - diff --git a/Day61-65/.gitkeep b/Day61-65/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Day66-75/66.网络爬虫和相关工具.md b/Day61-65/61.网络爬虫和相关工具.md similarity index 73% rename from Day66-75/66.网络爬虫和相关工具.md rename to Day61-65/61.网络爬虫和相关工具.md index 16aa85a..157fc8f 100644 --- a/Day66-75/66.网络爬虫和相关工具.md +++ b/Day61-65/61.网络爬虫和相关工具.md @@ -27,7 +27,6 @@ 大多数网站都会定义robots.txt文件,下面以淘宝的[robots.txt](http://www.taobao.com/robots.txt)文件为例,看看该网站对爬虫有哪些限制。 ``` - User-agent: Baiduspider Allow: /article Allow: /oshtml @@ -108,17 +107,17 @@ HTTP响应(响应行+响应头+空行+消息体): ![](./res/chrome-developer-tools.png) -2. POSTMAN:功能强大的网页调试与RESTful请求工具。 +2. Postman:功能强大的网页调试与RESTful请求工具。 ![](./res/postman.png) 3. HTTPie:命令行HTTP客户端。 - ```Shell + ```Bash pip3 install httpie ``` - ```Shell + ```Bash http --header http://www.scu.edu.cn HTTP/1.1 200 OK Accept-Ranges: bytes @@ -138,9 +137,9 @@ HTTP响应(响应行+响应头+空行+消息体): X-Frame-Options: SAMEORIGIN ``` -4. BuiltWith:识别网站所用技术的工具。 +4. `builtwith`库:识别网站所用技术的工具。 - ```Shell + ```Bash pip3 install builtwith ``` @@ -155,9 +154,9 @@ HTTP响应(响应行+响应头+空行+消息体): {'web-servers': ['Tengine'], 'web-frameworks': ['Twitter Bootstrap', 'Ruby on Rails'], 'programming-languages': ['Ruby']} ``` -5. python-whois:查询网站所有者的工具。 +5. `python-whois`库:查询网站所有者的工具。 - ```Shell + ```Bash pip3 install python-whois ``` @@ -167,7 +166,7 @@ HTTP响应(响应行+响应头+空行+消息体): {'domain_name': ['BAIDU.COM', 'baidu.com'], 'registrar': 'MarkMonitor, Inc.', 'whois_server': 'whois.markmonitor.com', 'referral_url': None, 'updated_date': [datetime.datetime(2017, 7, 28, 2, 36, 28), datetime.datetime(2017, 7, 27, 19, 36, 28)], 'creation_date': [datetime.datetime(1999, 10, 11, 11, 5, 17), datetime.datetime(1999, 10, 11, 4, 5, 17)], 'expiration_date': [datetime.datetime(2026, 10, 11, 11, 5, 17), datetime.datetime(2026, 10, 11, 0, 0)], 'name_servers': ['DNS.BAIDU.COM', 'NS2.BAIDU.COM', 'NS3.BAIDU.COM', 'NS4.BAIDU.COM', 'NS7.BAIDU.COM', 'dns.baidu.com', 'ns4.baidu.com', 'ns3.baidu.com', 'ns7.baidu.com', 'ns2.baidu.com'], 'status': ['clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited', 'clientTransferProhibited https://icann.org/epp#clientTransferProhibited', 'clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited', 'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', 'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', 'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited', 'clientUpdateProhibited (https://www.icann.org/epp#clientUpdateProhibited)', 'clientTransferProhibited (https://www.icann.org/epp#clientTransferProhibited)', 'clientDeleteProhibited (https://www.icann.org/epp#clientDeleteProhibited)', 'serverUpdateProhibited (https://www.icann.org/epp#serverUpdateProhibited)', 'serverTransferProhibited (https://www.icann.org/epp#serverTransferProhibited)', 'serverDeleteProhibited (https://www.icann.org/epp#serverDeleteProhibited)'], 'emails': ['abusecomplaints@markmonitor.com', 'whoisrelay@markmonitor.com'], 'dnssec': 'unsigned', 'name': None, 'org': 'Beijing Baidu Netcom Science Technology Co., Ltd.', 'address': None, 'city': None, 'state': 'Beijing', 'zipcode': None, 'country': 'CN'} ``` -6. robotparser:解析robots.txt的工具。 +6. `robotparser`模块:解析`robots.txt`的工具。 ```Python >>> from urllib import robotparser @@ -199,110 +198,106 @@ HTTP响应(响应行+响应头+空行+消息体): 下面的例子给出了一个从“搜狐体育”上获取NBA新闻标题和链接的爬虫。 ```Python -from urllib.error import URLError -from urllib.request import urlopen - import re -import pymysql -import ssl +from collections import deque +from urllib.parse import urljoin -from pymysql import Error +import requests + +LI_A_PATTERN = re.compile(r'
  • .*?
  • ') +A_TEXT_PATTERN = re.compile(r']*?>(.*?)') +A_HREF_PATTERN = re.compile(r']*?href="(.*?)"\s*[^>]*?>') -def decode_page(page_bytes, charsets=('utf-8',)): - """通过指定的字符集对页面进行解码(不是每个网站都将字符集设置为utf-8)""" - page_html = None +def decode_page(page_bytes, charsets): + """通过指定的字符集对页面进行解码""" for charset in charsets: try: - page_html = page_bytes.decode(charset) - break + return page_bytes.decode(charset) except UnicodeDecodeError: pass - # logging.error('Decode:', error) - return page_html -def get_page_html(seed_url, *, retry_times=3, charsets=('utf-8',)): - """获取页面的HTML代码(通过递归实现指定次数的重试操作)""" - page_html = None - try: - page_html = decode_page(urlopen(seed_url).read(), charsets) - except URLError: - # logging.error('URL:', error) - if retry_times > 0: - return get_page_html(seed_url, retry_times=retry_times - 1, - charsets=charsets) - return page_html +def get_matched_parts(content_string, pattern): + """从字符串中提取所有跟正则表达式匹配的内容""" + return pattern.findall(content_string, re.I) \ + if content_string else [] -def get_matched_parts(page_html, pattern_str, pattern_ignore_case=re.I): - """从页面中提取需要的部分(通常是链接也可以通过正则表达式进行指定)""" - pattern_regex = re.compile(pattern_str, pattern_ignore_case) - return pattern_regex.findall(page_html) if page_html else [] +def get_matched_part(content_string, pattern, group_no=1): + """从字符串中提取跟正则表达式匹配的内容""" + match = pattern.search(content_string) + if match: + return match.group(group_no) -def start_crawl(seed_url, match_pattern, *, max_depth=-1): - """开始执行爬虫程序并对指定的数据进行持久化操作""" - conn = pymysql.connect(host='localhost', port=3306, - database='crawler', user='root', - password='123456', charset='utf8') - try: - with conn.cursor() as cursor: - url_list = [seed_url] - # 通过下面的字典避免重复抓取并控制抓取深度 - visited_url_list = {seed_url: 0} - while url_list: - current_url = url_list.pop(0) - depth = visited_url_list[current_url] - if depth != max_depth: - # 尝试用utf-8/gbk/gb2312三种字符集进行页面解码 - page_html = get_page_html(current_url, charsets=('utf-8', 'gbk', 'gb2312')) - links_list = get_matched_parts(page_html, match_pattern) - param_list = [] - for link in links_list: - if link not in visited_url_list: - visited_url_list[link] = depth + 1 - page_html = get_page_html(link, charsets=('utf-8', 'gbk', 'gb2312')) - headings = get_matched_parts(page_html, r'

    (.*)]+test=a\s[^>]*href=["\'](.*?)["\']', - max_depth=2) + start_crawl( + seed_url='http://sports.sohu.com/nba_a.shtml', + pattern=LI_A_PATTERN, + max_depth=2 + ) if __name__ == '__main__': main() ``` -由于使用了MySQL实现持久化操作,所以要先启动MySQL服务器并创建名为`crawler`的数据库和名为`tb_result`的二维表才能运行该程序。 - ### 爬虫注意事项 通过上面的例子,我们对爬虫已经有了一个感性的认识,在编写爬虫时有以下一些注意事项: -1. 处理相对链接。有的时候我们从页面中获取的链接不是一个完整的绝对链接而是一个相对链接,这种情况下需要将其与URL前缀进行拼接(`urllib.parse`中的`urljoin()`函数可以完成此项操作)。 +1. 上面的代码使用了`requests`三方库来获取网络资源,这是一个非常优质的三方库,关于它的用法可以参考它的[官方文档](https://requests.readthedocs.io/zh_CN/latest/)。 -2. 设置代理服务。有些网站会限制访问的区域(例如美国的Netflix屏蔽了很多国家的访问),有些爬虫需要隐藏自己的身份,在这种情况下可以设置使用代理服务器,代理服务器有免费的服务器和付费的商业服务器,但后者稳定性和可用性都更好,强烈建议在商业项目中使用付费的代理服务器。可以通过修改`urllib.request`中的`ProxyHandler`来为请求设置代理服务器。 +2. 上面的代码中使用了双端队列(`deque`)来保存待爬取的URL。双端队列相当于是使用链式存储结构的`list`,在双端队列的头尾添加和删除元素性能都比较好,刚好可以用来构造一个FIFO(先进先出)的队列结构。 -3. 限制下载速度。如果我们的爬虫获取网页的速度过快,可能就会面临被封禁或者产生“损害动产”的风险(这个可能会导致吃官司且败诉),可以在两次下载之间添加延时从而对爬虫进行限速。 +3. 处理相对路径。有的时候我们从页面中获取的链接不是一个完整的绝对链接而是一个相对链接,这种情况下需要将其与URL前缀进行拼接(`urllib.parse`中的`urljoin()`函数可以完成此项操作)。 -4. 避免爬虫陷阱。有些网站会动态生成页面内容,这会导致产生无限多的页面(例如在线万年历通常会有无穷无尽的链接)。可以通过记录到达当前页面经过了多少个链接(链接深度)来解决该问题,当达到事先设定的最大深度时爬虫就不再像队列中添加该网页中的链接了。 +4. 设置代理服务。有些网站会限制访问的区域(例如美国的Netflix屏蔽了很多国家的访问),有些爬虫需要隐藏自己的身份,在这种情况下可以设置使用代理服务器,代理服务器有免费的服务器和付费的商业服务器,但后者稳定性和可用性都更好,强烈建议在商业项目中使用付费的商业代理服务器。如果使用`requests`三方库,可以在请求方法中添加`proxies`参数来指定代理服务器;如果使用标准库,可以通过修改`urllib.request`中的`ProxyHandler`来为请求设置代理服务器。 -5. SSL相关问题。在使用`urlopen`打开一个HTTPS链接时会验证一次SSL证书,如果不做出处理会产生错误提示“SSL: CERTIFICATE_VERIFY_FAILED”,可以通过以下两种方式加以解决: +5. 限制下载速度。如果我们的爬虫获取网页的速度过快,可能就会面临被封禁或者产生“损害动产”的风险(这个可能会导致吃官司且败诉),可以在两次获取页面数据之间添加延时从而对爬虫进行限速。 + +6. 避免爬虫陷阱。有些网站会动态生成页面内容,这会导致产生无限多的页面(例如在线万年历通常会有无穷无尽的链接)。可以通过记录到达当前页面经过了多少个链接(链接深度)来解决该问题,当达到事先设定的最大深度时,爬虫就不再像队列中添加该网页中的链接了。 + +7. 避开蜜罐链接。网站上的有些链接是浏览器中不可见的,这种链接通常是故意诱使爬虫去访问的蜜罐,一旦访问了这些链接,服务器就会判定请求是来自于爬虫的,这样可能会导致被服务器封禁IP地址。如何避开这些蜜罐链接我们在后面为大家进行讲解。 + +8. SSL相关问题。如果使用标准库的`urlopen`打开一个HTTPS链接时会验证一次SSL证书,如果不做出处理会产生错误提示“SSL: CERTIFICATE_VERIFY_FAILED”,可以通过以下两种方式加以解决: - 使用未经验证的上下文 diff --git a/Day61-65/61.预备知识.md b/Day61-65/61.预备知识.md deleted file mode 100644 index 4a95122..0000000 --- a/Day61-65/61.预备知识.md +++ /dev/null @@ -1,140 +0,0 @@ -## 预备知识 - -### 并发编程 - -所谓并发编程就是让程序中有多个部分能够并发或同时执行,并发编程带来的好处不言而喻,其中最为关键的两点是提升了执行效率和改善了用户体验。下面简单阐述一下Python中实现并发编程的三种方式: - -1. 多线程:Python中通过`threading`模块的`Thread`类并辅以`Lock`、`Condition`、`Event`、`Semaphore`和`Barrier`等类来支持多线程编程。Python解释器通过GIL(全局解释器锁)来防止多个线程同时执行本地字节码,这个锁对于CPython(Python解释器的官方实现)是必须的,因为CPython的内存管理并不是线程安全的。因为GIL的存在,Python的多线程并不能利用CPU的多核特性。 - -2. 多进程:使用多进程可以有效的解决GIL的问题,Python中的`multiprocessing`模块提供了`Process`类来实现多进程,其他的辅助类跟`threading`模块中的类类似,由于进程间的内存是相互隔离的(操作系统对进程的保护),进程间通信(共享数据)必须使用管道、套接字等方式,这一点从编程的角度来讲是比较麻烦的,为此,Python的`multiprocessing`模块提供了一个名为`Queue`的类,它基于管道和锁机制提供了多个进程共享的队列。 - - ```Python - """ - 用下面的命令运行程序并查看执行时间,例如: - time python3 example06.py - real 0m20.657s - user 1m17.749s - sys 0m0.158s - 使用多进程后实际执行时间为20.657秒,而用户时间1分17.749秒约为实际执行时间的4倍 - 这就证明我们的程序通过多进程使用了CPU的多核特性,而且这台计算机配置了4核的CPU - """ - import concurrent.futures - import math - - PRIMES = [ - 1116281, - 1297337, - 104395303, - 472882027, - 533000389, - 817504243, - 982451653, - 112272535095293, - 112582705942171, - 112272535095293, - 115280095190773, - 115797848077099, - 1099726899285419 - ] * 5 - - - def is_prime(num): - """判断素数""" - assert num > 0 - for i in range(2, int(math.sqrt(num)) + 1): - if num % i == 0: - return False - return num != 1 - - - def main(): - """主函数""" - with concurrent.futures.ProcessPoolExecutor() as executor: - for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): - print('%d is prime: %s' % (number, prime)) - - - if __name__ == '__main__': - main() - ``` - -3. 异步编程(异步I/O):所谓异步编程是通过调度程序从任务队列中挑选任务,调度程序以交叉的形式执行这些任务,我们并不能保证任务将以某种顺序去执行,因为执行顺序取决于队列中的一项任务是否愿意将CPU处理时间让位给另一项任务。异步编程通常通过多任务协作处理的方式来实现,由于执行时间和顺序的不确定,因此需要通过钩子函数(回调函数)或者`Future`对象来获取任务执行的结果。目前我们使用的Python 3通过`asyncio`模块以及`await`和`async`关键字(Python 3.5中引入,Python 3.7中正式成为关键字)提供了对异步I/O的支持。 - - ```Python - import asyncio - - - async def fetch(host): - """从指定的站点抓取信息(协程函数)""" - print(f'Start fetching {host}\n') - # 跟服务器建立连接 - reader, writer = await asyncio.open_connection(host, 80) - # 构造请求行和请求头 - writer.write(b'GET / HTTP/1.1\r\n') - writer.write(f'Host: {host}\r\n'.encode()) - writer.write(b'\r\n') - # 清空缓存区(发送请求) - await writer.drain() - # 接收服务器的响应(读取响应行和响应头) - line = await reader.readline() - while line != b'\r\n': - print(line.decode().rstrip()) - line = await reader.readline() - print('\n') - writer.close() - - - def main(): - """主函数""" - urls = ('www.sohu.com', 'www.douban.com', 'www.163.com') - # 获取系统默认的事件循环 - loop = asyncio.get_event_loop() - # 用生成式语法构造一个包含多个协程对象的列表 - tasks = [fetch(url) for url in urls] - # 通过asyncio模块的wait函数将协程列表包装成Task(Future子类)并等待其执行完成 - # 通过事件循环的run_until_complete方法运行任务直到Future完成并返回它的结果 - loop.run_until_complete(asyncio.wait(tasks)) - loop.close() - - - if __name__ == '__main__': - main() - ``` - - > 说明:目前大多数网站都要求基于HTTPS通信,因此上面例子中的网络请求不一定能收到正常的响应,也就是说响应状态码不一定是200,有可能是3xx或者4xx。当然我们这里的重点不在于获得网站响应的内容,而是帮助大家理解`asyncio`模块以及`async`和`await`两个关键字的使用。 - -我们对三种方式的使用场景做一个简单的总结。 - -以下情况需要使用多线程: - -1. 程序需要维护许多共享的状态(尤其是可变状态),Python中的列表、字典、集合都是线程安全的,所以使用线程而不是进程维护共享状态的代价相对较小。 -2. 程序会花费大量时间在I/O操作上,没有太多并行计算的需求且不需占用太多的内存。 - -以下情况需要使用多进程: - -1. 程序执行计算密集型任务(如:字节码操作、数据处理、科学计算)。 -2. 程序的输入可以并行的分成块,并且可以将运算结果合并。 -3. 程序在内存使用方面没有任何限制且不强依赖于I/O操作(如:读写文件、套接字等)。 - -最后,如果程序不需要真正的并发性或并行性,而是更多的依赖于异步处理和回调时,异步I/O就是一种很好的选择。另一方面,当程序中有大量的等待与休眠时,也应该考虑使用异步I/O。 - -> 扩展:关于进程,还需要做一些补充说明。首先,为了控制进程的执行,操作系统内核必须有能力挂起正在CPU上运行的进程,并恢复以前挂起的某个进程使之继续执行,这种行为被称为进程切换(也叫调度)。进程切换是比较耗费资源的操作,因为在进行切换时首先要保存当前进程的上下文(内核再次唤醒该进程时所需要的状态,包括:程序计数器、状态寄存器、数据栈等),然后还要恢复准备执行的进程的上下文。正在执行的进程由于期待的某些事件未发生,如请求系统资源失败、等待某个操作完成、新数据尚未到达等原因会主动由运行状态变为阻塞状态,当进程进入阻塞状态,是不占用CPU资源的。这些知识对于理解到底选择哪种方式进行并发编程也是很重要的。 - -### I/O模式和事件驱动 - -对于一次I/O操作(以读操作为例),数据会先被拷贝到操作系统内核的缓冲区中,然后从操作系统内核的缓冲区拷贝到应用程序的缓冲区(这种方式称为标准I/O或缓存I/O,大多数文件系统的默认I/O都是这种方式),最后交给进程。所以说,当一个读操作发生时(写操作与之类似),它会经历两个阶段:(1)等待数据准备就绪;(2)将数据从内核拷贝到进程中。 - -由于存在这两个阶段,因此产生了以下几种I/O模式: - -1. 阻塞 I/O(blocking I/O):进程发起读操作,如果内核数据尚未就绪,进程会阻塞等待数据直到内核数据就绪并拷贝到进程的内存中。 -2. 非阻塞 I/O(non-blocking I/O):进程发起读操作,如果内核数据尚未就绪,进程不阻塞而是收到内核返回的错误信息,进程收到错误信息可以再次发起读操作,一旦内核数据准备就绪,就立即将数据拷贝到了用户内存中,然后返回。 -3. 多路I/O复用( I/O multiplexing):监听多个I/O对象,当I/O对象有变化(数据就绪)的时候就通知用户进程。多路I/O复用的优势并不在于单个I/O操作能处理得更快,而是在于能处理更多的I/O操作。 -4. 异步 I/O(asynchronous I/O):进程发起读操作后就可以去做别的事情了,内核收到异步读操作后会立即返回,所以用户进程不阻塞,当内核数据准备就绪时,内核发送一个信号给用户进程,告诉它读操作完成了。 - -通常,我们编写一个处理用户请求的服务器程序时,有以下三种方式可供选择: - -1. 每收到一个请求,创建一个新的进程,来处理该请求; -2. 每收到一个请求,创建一个新的线程,来处理该请求; -3. 每收到一个请求,放入一个事件列表,让主进程通过非阻塞I/O方式来处理请求 - -第1种方式实现比较简单,但由于创建进程开销比较大,会导致服务器性能比较差;第2种方式,由于要涉及到线程的同步,有可能会面临竞争、死锁等问题;第3种方式,就是所谓事件驱动的方式,它利用了多路I/O复用和异步I/O的优点,虽然代码逻辑比前面两种都复杂,但能达到最好的性能,这也是目前大多数网络服务器采用的方式。 diff --git a/Day61-65/62.Tornado入门.md b/Day61-65/62.Tornado入门.md deleted file mode 100644 index e1249f8..0000000 --- a/Day61-65/62.Tornado入门.md +++ /dev/null @@ -1,377 +0,0 @@ -## Tornado入门 - -### Tornado概述 - -Python的Web框架种类繁多(比Python语言的关键字还要多),但在众多优秀的Web框架中,Tornado框架最适合用来开发需要处理长连接和应对高并发的Web应用。Tornado框架在设计之初就考虑到性能问题,通过对非阻塞I/O和epoll(Linux 2.5.44内核引入的一种多路I/O复用方式,旨在实现高性能网络服务,在BSD和macOS中是kqueue)的运用,Tornado可以处理大量的并发连接,更轻松的应对C10K(万级并发)问题,是非常理想的实时通信Web框架。 - -> 扩展:基于线程的Web服务器产品(如:Apache)会维护一个线程池来处理用户请求,当用户请求到达时就为该请求分配一个线程,如果线程池中没有空闲线程了,那么可以通过创建新的线程来应付新的请求,但前提是系统尚有空闲的内存空间,显然这种方式很容易将服务器的空闲内存耗尽(大多数Linux发行版本中,默认的线程栈大小为8M)。想象一下,如果我们要开发一个社交类应用,这类应用中,通常需要显示实时更新的消息、对象状态的变化和各种类型的通知,那也就意味着客户端需要保持请求连接来接收服务器的各种响应,在这种情况下,服务器上的工作线程很容易被耗尽,这也就意味着新的请求很有可能无法得到响应。 - -Tornado框架源于FriendFeed网站,在FriendFeed网站被Facebook收购之后得以开源,正式发布的日期是2009年9月10日。Tornado能让你能够快速开发高速的Web应用,如果你想编写一个可扩展的社交应用、实时分析引擎,或RESTful API,那么Tornado框架就是很好的选择。Tornado其实不仅仅是一个Web开发的框架,它还是一个高性能的事件驱动网络访问引擎,内置了高性能的HTTP服务器和客户端(支持同步和异步请求),同时还对WebSocket提供了完美的支持。 - -了解和学习Tornado最好的资料就是它的官方文档,在[tornadoweb.org](http://www.tornadoweb.org)上面有很多不错的例子,你也可以在Github上找到Tornado的源代码和历史版本。 - -### 5分钟上手Tornado - -1. 创建并激活虚拟环境。 - - ```Shell - mkdir hello-tornado - cd hello-tornado - python3 -m venv venv - source venv/bin/activate - ``` - -2. 安装Tornado。 - - ```Shell - pip install tornado - ``` - -3. 编写Web应用。 - - ```Python - """ - example01.py - """ - import tornado.ioloop - import tornado.web - - - class MainHandler(tornado.web.RequestHandler): - - def get(self): - self.write('

    Hello, world!

    ') - - - def main(): - app = tornado.web.Application(handlers=[(r'/', MainHandler), ]) - app.listen(8888) - tornado.ioloop.IOLoop.current().start() - - - if __name__ == '__main__': - main() - ``` - -4. 运行并访问应用。 - - ```Shell - python example01.py - ``` - - ![](./res/run-hello-world-app.png) - -在上面的例子中,代码example01.py通过定义一个继承自`RequestHandler`的类(`MainHandler`)来处理用户请求,当请求到达时,Tornado会实例化这个类(创建`MainHandler`对象),并调用与HTTP请求方法(GET、POST等)对应的方法,显然上面的`MainHandler`只能处理GET请求,在收到GET请求时,它会将一段HTML的内容写入到HTTP响应中。`main`函数的第1行代码创建了Tornado框架中`Application`类的实例,它代表了我们的Web应用,而创建该实例最为重要的参数就是`handlers`,该参数告知`Application`对象,当收到一个请求时应该通过哪个类的对象来处理这个请求。在上面的例子中,当通过HTTP的GET请求访问站点根路径时,就会调用`MainHandler`的`get`方法。 `main`函数的第2行代码通过`Application`对象的`listen`方法指定了监听HTTP请求的端口。`main`函数的第3行代码用于获取Tornado框架的`IOLoop`实例并启动它,该实例代表一个条件触发的I/O循环,用于持续的接收来自于客户端的请求。 - -> 扩展:在Python 3中,`IOLoop`实例的本质就是`asyncio`的事件循环,该事件循环在非Windows系统中就是`SelectorEventLoop`对象,它基于`selectors`模块(高级I/O复用模块),会使用当前操作系统最高效的I/O复用选择器,例如在Linux环境下它使用`EpollSelector`,而在macOS和BSD环境下它使用的是`KqueueSelector`;在Python 2中,`IOLoop`直接使用`select`模块(低级I/O复用模块)的`epoll`或`kqueue`函数,如果这两种方式都不可用,则调用`select`函数实现多路I/O复用。当然,如果要支持高并发,你的系统最好能够支持epoll或者kqueue这两种多路I/O复用方式中的一种。 - -如果希望通过命令行参数来指定Web应用的监听端口,可以对上面的代码稍作修改。 - -```Python -""" -example01.py -""" -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - - -# 定义默认端口 -define('port', default=8000, type=int) - - -class MainHandler(tornado.web.RequestHandler): - - def get(self): - self.write('

    Hello, world!

    ') - - -def main(): - # python example01.py --port=8000 - parse_command_line() - app = tornado.web.Application(handlers=[(r'/', MainHandler), ]) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() -``` - -在启动Web应用时,如果没有指定端口,将使用`define`函数中设置的默认端口8000,如果要指定端口,可以使用下面的方式来启动Web应用。 - -```Shell -python example01.py --port=8000 -``` - -### 路由解析 - -上面我们曾经提到过创建`Application`实例时需要指定`handlers`参数,这个参数非常重要,它应该是一个元组的列表,元组中的第一个元素是正则表达式,它用于匹配用户请求的资源路径;第二个元素是`RequestHandler`的子类。在刚才的例子中,我们只在`handlers`列表中放置了一个元组,事实上我们可以放置多个元组来匹配不同的请求(资源路径),而且可以使用正则表达式的捕获组来获取匹配的内容并将其作为参数传入到`get`、`post`这些方法中。 - -```Python -""" -example02.py -""" -import os -import random - -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - - -# 定义默认端口 -define('port', default=8000, type=int) - - -class SayingHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - sayings = [ - '世上没有绝望的处境,只有对处境绝望的人', - '人生的道路在态度的岔口一分为二,从此通向成功或失败', - '所谓措手不及,不是说没有时间准备,而是有时间的时候没有准备', - '那些你认为不靠谱的人生里,充满你没有勇气做的事', - '在自己喜欢的时间里,按照自己喜欢的方式,去做自己喜欢做的事,这便是自由', - '有些人不属于自己,但是遇见了也弥足珍贵' - ] - # 渲染index.html模板页 - self.render('index.html', message=random.choice(sayings)) - - -class WeatherHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self, city): - # Tornado框架会自动处理百分号编码的问题 - weathers = { - '北京': {'temperature': '-4~4', 'pollution': '195 中度污染'}, - '成都': {'temperature': '3~9', 'pollution': '53 良'}, - '深圳': {'temperature': '20~25', 'pollution': '25 优'}, - '广州': {'temperature': '18~23', 'pollution': '56 良'}, - '上海': {'temperature': '6~8', 'pollution': '65 良'} - } - if city in weathers: - self.render('weather.html', city=city, weather=weathers[city]) - else: - self.render('index.html', message=f'没有{city}的天气信息') - - -class ErrorHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - # 重定向到指定的路径 - self.redirect('/saying') - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - # handlers是按列表中的顺序依次进行匹配的 - handlers=[ - (r'/saying/?', SayingHandler), - (r'/weather/([^/]{2,})/?', WeatherHandler), - (r'/.+', ErrorHandler), - ], - # 通过template_path参数设置模板页的路径 - template_path=os.path.join(os.path.dirname(__file__), 'templates') - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() -``` - -模板页index.html。 - -```HTML - - - - - - Tornado基础 - - -

    {{message}}

    - - -``` - -模板页weather.html。 - -```HTML - - - - - - Tornado基础 - - -

    {{city}}

    -
    -

    温度:{{weather['temperature']}}摄氏度

    -

    污染指数:{{weather['pollution']}}

    - - -``` - -Tornado的模板语法与其他的Web框架中使用的模板语法并没有什么实质性的区别,而且目前的Web应用开发更倡导使用前端渲染的方式来减轻服务器的负担,所以这里我们并不对模板语法和后端渲染进行深入的讲解。 - -### 请求处理器 - -通过上面的代码可以看出,`RequestHandler`是处理用户请求的核心类,通过重写`get`、`post`、`put`、`delete`等方法可以处理不同类型的HTTP请求,除了这些方法之外,`RequestHandler`还实现了很多重要的方法,下面是部分方法的列表: - -1. `get_argument` / `get_arguments` / `get_body_argument` / `get_body_arguments` / `get_query_arugment` / `get_query_arguments`:获取请求参数。 -2. `set_status` / `send_error` / `set_header` / `add_header` / `clear_header` / `clear`:操作状态码和响应头。 -3. `write` / `flush` / `finish` / `write_error`:和输出相关的方法。 -4. `render` / `render_string`:渲染模板。 -5. `redirect`:请求重定向。 -6. `get_cookie` / `set_cookie` / `get_secure_cookie` / `set_secure_cookie` / `create_signed_value` / `clear_cookie` / `clear_all_cookies`:操作Cookie。 - -我们用上面讲到的这些方法来完成下面的需求,访问页面时,如果Cookie中没有读取到用户信息则要求用户填写个人信息,如果从Cookie中读取到用户信息则直接显示用户信息。 - -```Python -""" -example03.py -""" -import os -import re - -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - - -# 定义默认端口 -define('port', default=8000, type=int) - -users = {} - - -class User(object): - """用户""" - - def __init__(self, nickname, gender, birthday): - self.nickname = nickname - self.gender = gender - self.birthday = birthday - - -class MainHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - # 从Cookie中读取用户昵称 - nickname = self.get_cookie('nickname') - if nickname in users: - self.render('userinfo.html', user=users[nickname]) - else: - self.render('userform.html', hint='请填写个人信息') - - -class UserHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def post(self): - # 从表单参数中读取用户昵称、性别和生日信息 - nickname = self.get_body_argument('nickname').strip() - gender = self.get_body_argument('gender') - birthday = self.get_body_argument('birthday') - # 检查用户昵称是否有效 - if not re.fullmatch(r'\w{6,20}', nickname): - self.render('userform.html', hint='请输入有效的昵称') - elif nickname in users: - self.render('userform.html', hint='昵称已经被使用过') - else: - users[nickname] = User(nickname, gender, birthday) - # 将用户昵称写入Cookie并设置有效期为7天 - self.set_cookie('nickname', nickname, expires_days=7) - self.render('userinfo.html', user=users[nickname]) - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - handlers=[ - (r'/', MainHandler), (r'/register', UserHandler) - ], - template_path=os.path.join(os.path.dirname(__file__), 'templates') - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() -``` - -模板页userform.html。 - -```HTML - - - - - - Tornado基础 - - - -

    填写用户信息

    -
    -

    {{hint}}

    -
    -

    - - - (字母数字下划线,6-20个字符) -

    -

    - - 男 - 女 -

    -

    - - -

    -

    - -

    -
    - - -``` - -模板页userinfo.html。 - -```HTML - - - - - - Tornado基础 - - -

    用户信息

    -
    -

    昵称:{{user.nickname}}

    -

    性别:{{user.gender}}

    -

    出生日期:{{user.birthday}}

    - - -``` diff --git a/Day66-75/67.数据采集和解析.md b/Day61-65/62.数据采集和解析.md similarity index 55% rename from Day66-75/67.数据采集和解析.md rename to Day61-65/62.数据采集和解析.md index 52227ae..e8caf86 100644 --- a/Day66-75/67.数据采集和解析.md +++ b/Day61-65/62.数据采集和解析.md @@ -2,12 +2,12 @@ 通过上一个章节的讲解,我们已经了解到了开发一个爬虫需要做的工作以及一些常见的问题,下面我们给出一个爬虫开发相关技术的清单以及这些技术涉及到的标准库和第三方库,稍后我们会一一介绍这些内容。 -1. 下载数据 - **urllib** / **requests** / **aiohttp**。 +1. 下载数据 - **urllib** / **requests** / **aiohttp** / **httpx**。 2. 解析数据 - **re** / **lxml** / **beautifulsoup4** / **pyquery**。 -3. 缓存和持久化 - **pymysql** / **sqlalchemy** / **peewee**/ **redis** / **pymongo**。 +3. 缓存和持久化 - **mysqlclient** / **sqlalchemy** / **peewee** / **redis** / **pymongo**。 4. 生成数字签名 - **hashlib**。 5. 序列化和压缩 - **pickle** / **json** / **zlib**。 -6. 调度器 - 多进程(**multiprocessing**) / 多线程(**threading**)。 +6. 调度器 - **multiprocessing** / **threading** / **concurrent.futures**。 ### HTML页面 @@ -79,47 +79,93 @@

    ``` -如果你对上面的代码并不感到陌生,那么你一定知道HTML页面通常由三部分构成,分别是用来承载内容的Tag(标签)、负责渲染页面的CSS(层叠样式表)以及控制交互式行为的JavaScript。通常,我们可以在浏览器的右键菜单中通过“查看网页源代码”的方式获取网页的代码并了解页面的结构;当然,我们也可以通过浏览器提供的开发人员工具来了解更多的信息。 +如上所示的HTML页面通常由三部分构成,分别是用来承载内容的Tag(标签)、负责渲染页面的CSS(层叠样式表)以及控制交互式行为的JavaScript。通常,我们可以在浏览器的右键菜单中通过“查看网页源代码”的方式获取网页的代码并了解页面的结构;当然,我们也可以通过浏览器提供的开发人员工具来了解更多的信息。 #### 使用requests获取页面 +在上一节课的代码中我们使用了三方库`requests`来获取页面,下面我们对`requests`库的用法做进一步说明。 + 1. GET请求和POST请求。 ```Python + import requests + resp = requests.get('http://www.baidu.com/index.html') + print(resp.status_code) + print(resp.headers) + print(resp.cookies) + print(resp.content.decode('utf-8')) + + resp = requests.post('http://httpbin.org/post', data={'name': 'Hao', 'age': 40}) + print(resp.text) + data = resp.json() + print(type(data)) ``` 2. URL参数和请求头。 ```Python - + resp = requests.get( + url='https://movie.douban.com/top250', + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/83.0.4103.97 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;' + 'q=0.9,image/webp,image/apng,*/*;' + 'q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + } + ) + print(resp.status_code) ``` 3. 复杂的POST请求(文件上传)。 ```Python - + resp = requests.post( + url='http://httpbin.org/post', + files={'file': open('data.xlsx', 'rb')} + ) + print(resp.text) ``` 4. 操作Cookie。 ```Python + cookies = {'key1': 'value1', 'key2': 'value2'} + resp = requests.get('http://httpbin.org/cookies', cookies=cookies) + print(resp.text) + jar = requests.cookies.RequestsCookieJar() + jar.set('tasty_cookie', 'yum', domain='httpbin.org', path='/cookies') + jar.set('gross_cookie', 'blech', domain='httpbin.org', path='/elsewhere') + resp = requests.get('http://httpbin.org/cookies', cookies=jar) + print(resp.text) ``` 5. 设置代理服务器。 ```Python - + requests.get('https://www.taobao.com', proxies={ + 'http': 'http://10.10.1.10:3128', + 'https': 'http://10.10.1.10:1080', + }) ``` + + > **说明**:关于`requests`库的相关知识,还是强烈建议大家自行阅读它的[官方文档](https://requests.readthedocs.io/zh_CN/latest/)。 + +6. 设置请求超时。 -> 说明:关于requests的详细用法可以参考它的[官方文档](http://docs.python-requests.org/zh_CN/latest/user/quickstart.html)。 + ```Python + requests.get('https://github.com', timeout=10) + ``` ### 页面解析 @@ -131,13 +177,41 @@ | XPath解析 | lxml | 快 | 一般 | 需要安装C语言依赖库
    唯一支持XML的解析器 | | CSS选择器解析 | bs4 / pyquery | 不确定 | 简单 | | -> 说明:BeautifulSoup可选的解析器包括:Python标准库(html.parser)、lxml的HTML解析器、lxml的XML解析器和html5lib。 +> **说明**:`BeautifulSoup`可选的解析器包括:Python标准库中的`html.parser`、`lxml`的HTML解析器、`lxml`的XML解析器和`html5lib`。 #### 使用正则表达式解析页面 -如果你对正则表达式没有任何的概念,那么推荐先阅读[《正则表达式30分钟入门教程》](),然后再阅读我们之前讲解在Python中如何使用正则表达式一文。 +如果你对正则表达式没有任何的概念,那么推荐先阅读[《正则表达式30分钟入门教程》](https://deerchao.cn/tutorials/regex/regex.htm),然后再阅读我们之前讲解在Python中如何使用正则表达式一文。 +下面的例子演示了如何用正则表达式解析“豆瓣电影Top250”中的中文电影名称。 +```Python +import random +import re +import time + +import requests + +PATTERN = re.compile(r']*?>\s*(.*?)') + +for page in range(10): + resp = requests.get( + url=f'https://movie.douban.com/top250?start={page * 25}', + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/83.0.4103.97 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;' + 'q=0.9,image/webp,image/apng,*/*;' + 'q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + }, + ) + items = PATTERN.findall(resp.text) + for item in items: + print(item) + time.sleep(random.randint(1, 5)) +``` #### XPath解析和lxml @@ -196,13 +270,37 @@ XPath还支持通配符用法,如下所示。 | //title \| //price | 选取文档中的所有 title 和 price 元素。 | | /bookstore/book/title \| //price | 选取属于 bookstore 元素的 book 元素的所有 title 元素,以及文档中所有的 price 元素。 | -> 说明:上面的例子来自于菜鸟教程网站上[XPath教程](),有兴趣的读者可以自行阅读原文。 +> **说明**:上面的例子来自于菜鸟教程网站上[XPath教程](),有兴趣的读者可以自行阅读原文。 当然,如果不理解或者不太熟悉XPath语法,可以在Chrome浏览器中按照如下所示的方法查看元素的XPath语法。 ![](./res/douban-xpath.png) +下面的例子演示了如何用XPath解析“豆瓣电影Top250”中的中文电影名称。 +```Python +from lxml import etree + +import requests + +for page in range(10): + resp = requests.get( + url=f'https://movie.douban.com/top250?start={page * 25}', + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/83.0.4103.97 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;' + 'q=0.9,image/webp,image/apng,*/*;' + 'q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + } + ) + html = etree.HTML(resp.text) + spans = html.xpath('/html/body/div[3]/div[1]/div/div[1]/ol/li/div/div[2]/div[1]/a/span[1]') + for span in spans: + print(span.text) +``` ### BeautifulSoup的使用 @@ -219,42 +317,63 @@ BeautifulSoup是一个可以从HTML或XML文件中提取数据的Python库。它 - find / find_all - select_one / select -> 说明:更多内容可以参考BeautifulSoup的[官方文档](https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.zh.html)。 +> **说明**:更多内容可以参考BeautifulSoup的[官方文档](https://beautifulsoup.readthedocs.io/zh_CN/v4.4.0/)。 -### PyQuery的使用 - -pyquery相当于jQuery的Python实现,可以用于解析HTML网页。 - -### 实例 - 获取知乎发现上的问题链接 +下面的例子演示了如何用CSS选择器解析“豆瓣电影Top250”中的中文电影名称。 ```Python -from urllib.parse import urljoin +import random +import time -import re +import bs4 import requests -from bs4 import BeautifulSoup +for page in range(10): + resp = requests.get( + url=f'https://movie.douban.com/top250?start={page * 25}', + headers={ + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) ' + 'AppleWebKit/537.36 (KHTML, like Gecko) ' + 'Chrome/83.0.4103.97 Safari/537.36', + 'Accept': 'text/html,application/xhtml+xml,application/xml;' + 'q=0.9,image/webp,image/apng,*/*;' + 'q=0.8,application/signed-exchange;v=b3;q=0.9', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + }, + ) + soup = bs4.BeautifulSoup(resp.text, 'lxml') + elements = soup.select('.info>div>a') + for element in elements: + span = element.select_one('.title') + print(span.text) + time.sleep(random.random() * 5) + +``` + +### 例子 - 获取知乎发现上的问题链接 + +```Python +import re +from urllib.parse import urljoin + +import bs4 +import requests def main(): headers = {'user-agent': 'Baiduspider'} - proxies = { - 'http': 'http://122.114.31.177:808' - } base_url = 'https://www.zhihu.com/' - seed_url = urljoin(base_url, 'explore') - resp = requests.get(seed_url, - headers=headers, - proxies=proxies) - soup = BeautifulSoup(resp.text, 'lxml') + resp = requests.get(urljoin(base_url, 'explore'), headers=headers) + soup = bs4.BeautifulSoup(resp.text, 'lxml') href_regex = re.compile(r'^/question') - link_set = set() + links_set = set() for a_tag in soup.find_all('a', {'href': href_regex}): if 'href' in a_tag.attrs: href = a_tag.attrs['href'] full_url = urljoin(base_url, href) - link_set.add(full_url) - print('Total %d question pages found.' % len(link_set)) + links_set.add(full_url) + print('Total %d question pages found.' % len(links_set)) + print(links_set) if __name__ == '__main__': diff --git a/Day61-65/63.存储数据.md b/Day61-65/63.存储数据.md new file mode 100644 index 0000000..9857293 --- /dev/null +++ b/Day61-65/63.存储数据.md @@ -0,0 +1,118 @@ +## 存储数据 + +### 存储海量数据 + +数据持久化的首选方案应该是关系型数据库,关系型数据库的产品很多,包括:Oracle、MySQL、SQLServer、PostgreSQL等。如果要存储海量的低价值数据,文档数据库也是不错的选择,MongoDB是文档数据库中的佼佼者,有兴趣的读者可以自行研究。 + +下面的代码演示了如何使用MySQL来保存从知乎发现上爬取到的链接和页面。 + +```SQL +create database zhihu default charset utf8; +create user 'hellokitty'@'%' identified by 'Hellokitty.618'; +grant all privileges on zhihu.* to 'hellokitty'@'%'; +flush privileges; + +use zhihu; +create table `tb_explore` +( + `id` integer auto_increment, + `url` varchar(1024) not null, + `page` longblob not null, + `digest` char(48) unique not null, + `idate` datetime default now(), + primary key (`id`) +); +``` + +```Python +import hashlib +import pickle +import re +import zlib +from urllib.parse import urljoin + +import MySQLdb +import bs4 +import requests + +conn = MySQLdb.connect(host='1.2.3.4', port=3306, + user='hellokitty', password='Hellokitty.618', + database='zhihu', charset='utf8', + autocommit=True) + + +def write_to_db(url, page, digest): + try: + with conn.cursor() as cursor: + cursor.execute( + 'insert into tb_explore (url, page, digest) values (%s, %s, %s) ', + (url, page, digest) + ) + except MySQLdb.MySQLError as err: + print(err) + + +def main(): + base_url = 'https://www.zhihu.com/' + seed_url = urljoin(base_url, 'explore') + headers = {'user-agent': 'Baiduspider'} + try: + resp = requests.get(seed_url, headers=headers) + soup = bs4.BeautifulSoup(resp.text, 'lxml') + href_regex = re.compile(r'^/question') + for a_tag in soup.find_all('a', {'href': href_regex}): + href = a_tag.attrs['href'] + full_url = urljoin(base_url, href) + digest = hashlib.sha1(full_url.encode()).hexdigest() + html_page = requests.get(full_url, headers=headers).text + zipped_page = zlib.compress(pickle.dumps(html_page)) + write_to_db(full_url, zipped_page, digest) + finally: + conn.close() + + +if __name__ == '__main__': + main() +``` + +### 数据缓存 + +通过[《网络数据采集和解析》](./67.数据采集和解析.md)一文,我们已经知道了如何从指定的页面中抓取数据,以及如何保存抓取的结果,但是我们没有考虑过这么一种情况,就是我们可能需要从已经抓取过的页面中提取出更多的数据,重新去下载这些页面对于规模不大的网站倒是问题也不大,但是如果能够把这些页面缓存起来,对应用的性能会有明显的改善。下面的例子演示了如何使用Redis来缓存知乎发现上的页面。 + +```Python +import hashlib +import pickle +import re +import zlib +from urllib.parse import urljoin + +import bs4 +import redis +import requests + + +def main(): + base_url = 'https://www.zhihu.com/' + seed_url = urljoin(base_url, 'explore') + client = redis.Redis(host='1.2.3.4', port=6379, password='1qaz2wsx') + headers = {'user-agent': 'Baiduspider'} + resp = requests.get(seed_url, headers=headers) + soup = bs4.BeautifulSoup(resp.text, 'lxml') + href_regex = re.compile(r'^/question') + for a_tag in soup.find_all('a', {'href': href_regex}): + href = a_tag.attrs['href'] + full_url = urljoin(base_url, href) + field_key = hashlib.sha1(full_url.encode()).hexdigest() + if not client.hexists('spider:zhihu:explore', field_key): + html_page = requests.get(full_url, headers=headers).text + zipped_page = zlib.compress(pickle.dumps(html_page)) + client.hset('spider:zhihu:explore', field_key, zipped_page) + print('Total %d question pages found.' % client.hlen('spider:zhihu:explore')) + + +if __name__ == '__main__': + main() +``` + + + diff --git a/Day61-65/63.异步化.md b/Day61-65/63.异步化.md deleted file mode 100644 index 07963ca..0000000 --- a/Day61-65/63.异步化.md +++ /dev/null @@ -1,152 +0,0 @@ -## 异步化 - -在前面的例子中,我们并没有对`RequestHandler`中的`get`或`post`方法进行异步处理,这就意味着,一旦在`get`或`post`方法中出现了耗时间的操作,不仅仅是当前请求被阻塞,按照Tornado框架的工作模式,其他的请求也会被阻塞,所以我们需要对耗时间的操作进行异步化处理。 - -在Tornado稍早一些的版本中,可以用装饰器实现请求方法的异步化或协程化来解决这个问题。 - -- 给`RequestHandler`的请求处理函数添加`@tornado.web.asynchronous`装饰器,如下所示: - - ```Python - class AsyncReqHandler(RequestHandler): - - @tornado.web.asynchronous - def get(self): - http = httpclient.AsyncHTTPClient() - http.fetch("http://example.com/", self._on_download) - - def _on_download(self, response): - do_something_with_response(response) - self.render("template.html") - ``` - -- 给`RequestHandler`的请求处理函数添加`@tornado.gen.coroutine`装饰器,如下所示: - - ```Python - class GenAsyncHandler(RequestHandler): - - @tornado.gen.coroutine - def get(self): - http_client = AsyncHTTPClient() - response = yield http_client.fetch("http://example.com") - do_something_with_response(response) - self.render("template.html") - ``` - -- 使用`@return_future`装饰器,如下所示: - - ```Python - @return_future - def future_func(arg1, arg2, callback): - # Do stuff (possibly asynchronous) - callback(result) - - async def caller(): - await future_func(arg1, arg2) - ``` - -在Tornado 5.x版本中,这几个装饰器都被标记为**deprcated**(过时),我们可以通过Python 3.5中引入的`async`和`await`(在Python 3.7中已经成为正式的关键字)来达到同样的效果。当然,要实现异步化还得靠其他的支持异步操作的三方库来支持,如果请求处理函数中用到了不支持异步操作的三方库,就需要靠自己写包装类来支持异步化。 - -下面的代码演示了在读写数据库时如何实现请求处理的异步化。我们用到的数据库建表语句如下所示: - -```SQL -create database hrs default charset utf8; - -use hrs; - -/* 创建部门表 */ -create table tb_dept -( - dno int not null comment '部门编号', - dname varchar(10) not null comment '部门名称', - dloc varchar(20) not null comment '部门所在地', - primary key (dno) -); - -insert into tb_dept values - (10, '会计部', '北京'), - (20, '研发部', '成都'), - (30, '销售部', '重庆'), - (40, '运维部', '深圳'); -``` - -我们通过下面的代码实现了查询和新增部门两个操作。 - -```Python -import json - -import aiomysql -import tornado -import tornado.web - -from tornado.ioloop import IOLoop -from tornado.options import define, parse_command_line, options - -define('port', default=8000, type=int) - - -async def connect_mysql(): - return await aiomysql.connect( - host='120.77.222.217', - port=3306, - db='hrs', - user='root', - password='123456', - ) - - -class HomeHandler(tornado.web.RequestHandler): - - async def get(self, no): - async with self.settings['mysql'].cursor(aiomysql.DictCursor) as cursor: - await cursor.execute("select * from tb_dept where dno=%s", (no, )) - if cursor.rowcount == 0: - self.finish(json.dumps({ - 'code': 20001, - 'mesg': f'没有编号为{no}的部门' - })) - return - row = await cursor.fetchone() - self.finish(json.dumps(row)) - - async def post(self, *args, **kwargs): - no = self.get_argument('no') - name = self.get_argument('name') - loc = self.get_argument('loc') - conn = self.settings['mysql'] - try: - async with conn.cursor() as cursor: - await cursor.execute('insert into tb_dept values (%s, %s, %s)', - (no, name, loc)) - await conn.commit() - except aiomysql.MySQLError: - self.finish(json.dumps({ - 'code': 20002, - 'mesg': '添加部门失败请确认部门信息' - })) - else: - self.set_status(201) - self.finish() - - -def make_app(config): - return tornado.web.Application( - handlers=[(r'/api/depts/(.*)', HomeHandler), ], - **config - ) - - -def main(): - parse_command_line() - app = make_app({ - 'debug': True, - 'mysql': IOLoop.current().run_sync(connect_mysql) - }) - app.listen(options.port) - IOLoop.current().start() - - -if __name__ == '__main__': - main() -``` - -上面的代码中,我们用到了`aiomysql`这个三方库,它基于`pymysql`封装,实现了对MySQL操作的异步化。操作Redis可以使用`aioredis`,访问MongoDB可以使用`motor`,这些都是支持异步操作的三方库。 \ No newline at end of file diff --git a/Day61-65/64.WebSocket的应用.md b/Day61-65/64.WebSocket的应用.md deleted file mode 100644 index ef25c9e..0000000 --- a/Day61-65/64.WebSocket的应用.md +++ /dev/null @@ -1,228 +0,0 @@ -## WebSocket的应用 - -Tornado的异步特性使其非常适合处理高并发的业务,同时也适合那些需要在客户端和服务器之间维持长连接的业务。传统的基于HTTP协议的Web应用,服务器和客户端(浏览器)的通信只能由客户端发起,这种单向请求注定了如果服务器有连续的状态变化,客户端(浏览器)是很难得知的。事实上,今天的很多Web应用都需要服务器主动向客户端(浏览器)发送数据,我们将这种通信方式称之为“推送”。过去很长一段时间,程序员都是用定时轮询(Polling)或长轮询(Long Polling)等方式来实现“推送”,但是这些都不是真正意义上的“推送”,而且浪费资源且效率低下。在HTML5时代,可以通过一种名为WebSocket的技术在服务器和客户端(浏览器)之间维持传输数据的长连接,这种方式可以实现真正的“推送”服务。 - -### WebSocket简介 - -WebSocket 协议在2008年诞生,2011年成为国际标准([RFC 6455](https://tools.ietf.org/html/rfc6455)),现在的浏览器都能够支持它,它可以实现浏览器和服务器之间的全双工通信。我们之前学习或了解过Python的Socket编程,通过Socket编程,可以基于TCP或UDP进行数据传输;而WebSocket与之类似,只不过它是基于HTTP来实现通信握手,使用TCP来进行数据传输。WebSocket的出现打破了HTTP请求和响应只能一对一通信的模式,也改变了服务器只能被动接受客户端请求的状况。目前有很多Web应用是需要服务器主动向客户端发送信息的,例如股票信息的网站可能需要向浏览器发送股票涨停通知,社交网站可能需要向用户发送好友上线提醒或聊天信息。 - -![](./res/websocket.png) - -WebSocket的特点如下所示: - -1. 建立在TCP协议之上,服务器端的实现比较容易。 -2. 与HTTP协议有着良好的兼容性,默认端口是80(WS)和443(WSS),通信握手阶段采用HTTP协议,能通过各种 HTTP 代理服务器(不容易被防火墙阻拦)。 -3. 数据格式比较轻量,性能开销小,通信高效。 -4. 可以发送文本,也可以发送二进制数据。 -5. 没有同源策略的限制,客户端(浏览器)可以与任意服务器通信。 - -![](./res/ws_wss.png) - -### WebSocket服务器端编程 - -Tornado框架中有一个`tornado.websocket.WebSocketHandler`类专门用于处理来自WebSocket的请求,通过继承该类并重写`open`、`on_message`、`on_close` 等方法来处理WebSocket通信,下面我们对`WebSocketHandler`的核心方法做一个简单的介绍。 - -1. `open(*args, **kwargs)`方法:建立新的WebSocket连接后,Tornado框架会调用该方法,该方法的参数与`RequestHandler`的`get`方法的参数类似,这也就意味着在`open`方法中可以执行获取请求参数、读取Cookie信息这样的操作。 - -2. `on_message(message)`方法:建立WebSocket之后,当收到来自客户端的消息时,Tornado框架会调用该方法,这样就可以对收到的消息进行对应的处理,必须重写这个方法。 - -3. `on_close()`方法:当WebSocket被关闭时,Tornado框架会调用该方法,在该方法中可以通过`close_code`和`close_reason`了解关闭的原因。 - -4. `write_message(message, binary=False)`方法:将指定的消息通过WebSocket发送给客户端,可以传递utf-8字符序列或者字节序列,如果message是一个字典,将会执行JSON序列化。正常情况下,该方法会返回一个`Future`对象;如果WebSocket被关闭了,将引发`WebSocketClosedError`。 - -5. `set_nodelay(value)`方法:默认情况下,因为TCP的Nagle算法会导致短小的消息被延迟发送,在考虑到交互性的情况下就要通过将该方法的参数设置为`True`来避免延迟。 - -6. `close(code=None, reason=None)`方法:主动关闭WebSocket,可以指定状态码(详见[RFC 6455 7.4.1节](https://tools.ietf.org/html/rfc6455#section-7.4.1))和原因。 - -### WebSocket客户端编程 - -1. 创建WebSocket对象。 - - ```JavaScript - var webSocket = new WebSocket('ws://localhost:8000/ws'); - ``` - - >说明:webSocket对象的readyState属性表示该对象当前状态,取值为CONNECTING-正在连接,OPEN-连接成功可以通信,CLOSING-正在关闭,CLOSED-已经关闭。 - -2. 编写回调函数。 - - ```JavaScript - webSocket.onopen = function(evt) { webSocket.send('...'); }; - webSocket.onmessage = function(evt) { console.log(evt.data); }; - webSocket.onclose = function(evt) {}; - webSocket.onerror = function(evt) {}; - ``` - - > 说明:如果要绑定多个事件回调函数,可以用addEventListener方法。另外,通过事件对象的data属性获得的数据可能是字符串,也有可能是二进制数据,可以通过webSocket对象的binaryType属性(blob、arraybuffer)或者通过typeof、instanceof运算符检查类型进行判定。 - -### 项目:Web聊天室 - -```Python -""" -handlers.py - 用户登录和聊天的处理器 -""" -import tornado.web -import tornado.websocket - -nicknames = set() -connections = {} - - -class LoginHandler(tornado.web.RequestHandler): - - def get(self): - self.render('login.html', hint='') - - def post(self): - nickname = self.get_argument('nickname') - if nickname in nicknames: - self.render('login.html', hint='昵称已被使用,请更换昵称') - self.set_secure_cookie('nickname', nickname) - self.render('chat.html') - - -class ChatHandler(tornado.websocket.WebSocketHandler): - - def open(self): - nickname = self.get_secure_cookie('nickname').decode() - nicknames.add(nickname) - for conn in connections.values(): - conn.write_message(f'~~~{nickname}进入了聊天室~~~') - connections[nickname] = self - - def on_message(self, message): - nickname = self.get_secure_cookie('nickname').decode() - for conn in connections.values(): - if conn is not self: - conn.write_message(f'{nickname}说:{message}') - - def on_close(self): - nickname = self.get_secure_cookie('nickname').decode() - del connections[nickname] - nicknames.remove(nickname) - for conn in connections.values(): - conn.write_message(f'~~~{nickname}离开了聊天室~~~') - -``` - -```Python -""" -run_chat_server.py - 聊天服务器 -""" -import os - -import tornado.web -import tornado.ioloop - -from handlers import LoginHandler, ChatHandler - - -if __name__ == '__main__': - app = tornado.web.Application( - handlers=[(r'/login', LoginHandler), (r'/chat', ChatHandler)], - template_path=os.path.join(os.path.dirname(__file__), 'templates'), - static_path=os.path.join(os.path.dirname(__file__), 'static'), - cookie_secret='MWM2MzEyOWFlOWRiOWM2MGMzZThhYTk0ZDNlMDA0OTU=', - ) - app.listen(8888) - tornado.ioloop.IOLoop.current().start() -``` - -```HTML - - - - - - Tornado聊天室 - - - -
    -
    -

    进入聊天室

    -
    -

    {{hint}}

    -
    - - - -
    -
    -
    - - -``` - -```HTML - - - - - - Tornado聊天室 - - -

    聊天室

    -
    -
    - -
    -
    - - -
    -

    - 退出聊天室 -

    - - - - -``` - diff --git a/Day66-75/69.并发下载.md b/Day61-65/64.并发下载.md similarity index 64% rename from Day66-75/69.并发下载.md rename to Day61-65/64.并发下载.md index a5c36c8..3b36f9c 100644 --- a/Day66-75/69.并发下载.md +++ b/Day61-65/64.并发下载.md @@ -1,14 +1,12 @@ ## 并发下载 -### 多线程和多进程回顾 - -在前面的[《进程和线程》](../Day01-15/Day13/进程和线程.md)一文中,我们已经对在Python中使用多进程和多线程实现并发编程进行了简明的讲解,在此我们补充几个知识点。 +### 多线程和多进程补充知识点 #### threading.local类 使用线程时最不愿意遇到的情况就是多个线程竞争资源,在这种情况下为了保证资源状态的正确性,我们可能需要对资源进行加锁保护的处理,这一方面会导致程序失去并发性,另外如果多个线程竞争多个资源时,还有可能因为加锁方式的不当导致[死锁](https://zh.wikipedia.org/wiki/%E6%AD%BB%E9%94%81)。要解决多个线程竞争资源的问题,其中一个方案就是让每个线程都持有资源的副本(拷贝),这样每个线程可以操作自己所持有的资源,从而规避对资源的竞争。 -要实现将资源和持有资源的线程进行绑定的操作,最简单的做法就是使用threading模块的local类,在网络爬虫开发中,就可以使用local类为每个线程绑定一个MySQL数据库连接或Redis客户端对象,这样通过线程可以直接获得这些资源,既解决了资源竞争的问题,又避免了在函数和方法调用时传递这些资源。具体的请参考本章多线程爬取“手机搜狐网”(Redis版)的实例代码。 +要实现将资源和持有资源的线程进行绑定的操作,最简单的做法就是使用`threading`模块的`local`类,在网络爬虫开发中,就可以使用`local`类为每个线程绑定一个MySQL数据库连接或Redis客户端对象,这样通过线程可以直接获得这些资源,既解决了资源竞争的问题,又避免了在函数和方法调用时传递这些资源。具体的请参考本章多线程爬取“手机搜狐网”(Redis版)的实例代码。 #### concurrent.futures模块 @@ -29,7 +27,7 @@ Python3.2带来了`concurrent.futures` 模块,这个模块包含了线程池 1. 执行效率极高,因为子程序(函数)切换不是线程切换,由程序自身控制,没有切换线程的开销。 2. 不需要多线程的锁机制,因为只有一个线程,也不存在竞争资源的问题,当然也就不需要对资源加锁保护,因此执行效率高很多。 -> 说明:协程适合处理的是I/O密集型任务,处理CPU密集型任务并不是它的长处,如果要提升CPU的利用率可以考虑“多进程+协程”的模式。 +> **说明**:协程适合处理的是I/O密集型任务,处理CPU密集型任务并不是它擅长的,如果要提升CPU的利用率可以考虑“多进程+多线程”或者“多进程+协程”的工作模式。 #### 历史回顾 @@ -39,176 +37,39 @@ Python3.2带来了`concurrent.futures` 模块,这个模块包含了线程池 4. Python 3.4:引入`asyncio.coroutine`装饰器用来标记作为协程的函数,协程函数和`asyncio`及其事件循环一起使用,来实现异步I/O操作。 5. Python 3.5:引入了`async`和`await`,可以使用`async def`来定义一个协程函数,这个函数中不能包含任何形式的`yield`语句,但是可以使用`return`或`await`从协程中返回值。 -#### 示例代码 +协程实现了协作式并发,通过提高CPU的利用率来达到改善性能的目的。著名的三方库[`aiohttp`](https://github.com/aio-libs/aiohttp)就是通过协程的方式实现了HTTP客户端和HTTP服务器的功能,较之`requests`有更好的获取数据的性能,有兴趣可以阅读它的[官方文档](https://aiohttp.readthedocs.io/en/stable/)。 -1. 生成器 - 数据的生产者。 +```Python +import asyncio +import aiohttp - ```Python - from time import sleep - - - # 倒计数生成器 - def countdown(n): - while n > 0: - yield n - n -= 1 - - - def main(): - for num in countdown(5): - print(f'Countdown: {num}') - sleep(1) - print('Countdown Over!') - - - if __name__ == '__main__': - main() - - ``` - 生成器还可以叠加来组成生成器管道,代码如下所示。 +async def download(url): + print('Fetch:', url) + async with aiohttp.ClientSession() as session: + async with session.get(url, ssl=False) as resp: + print(url, '--->', resp.status) + print(url, '--->', resp.headers) + print('\n\n', await resp.text()) - ```Python - # Fibonacci数生成器 - def fib(): - a, b = 0, 1 - while True: - a, b = b, a + b - yield a - - - # 偶数生成器 - def even(gen): - for val in gen: - if val % 2 == 0: - yield val - - - def main(): - gen = even(fib()) - for _ in range(10): - print(next(gen)) - - - if __name__ == '__main__': - main() - ``` -2. 协程 - 数据的消费者。 +def main(): + loop = asyncio.get_event_loop() + urls = [ + 'https://www.baidu.com', + 'http://www.sohu.com/', + 'http://www.sina.com.cn/', + 'https://www.taobao.com/', + 'http://jd.com/' + ] + tasks = [download(url) for url in urls] + loop.run_until_complete(asyncio.wait(tasks)) + loop.close() - ```Python - from time import sleep - - - # 生成器 - 数据生产者 - def countdown_gen(n, consumer): - consumer.send(None) - while n > 0: - consumer.send(n) - n -= 1 - consumer.send(None) - - - # 协程 - 数据消费者 - def countdown_con(): - while True: - n = yield - if n: - print(f'Countdown {n}') - sleep(1) - else: - print('Countdown Over!') - - - def main(): - countdown_gen(5, countdown_con()) - - - if __name__ == '__main__': - main() - ``` - > 说明:上面代码中countdown_gen函数中的第1行consumer.send(None)是为了激活生成器,通俗的说就是让生成器执行到有yield关键字的地方挂起,当然也可以通过next(consumer)来达到同样的效果。如果不愿意每次都用这样的代码来“预激”生成器,可以写一个包装器来完成该操作,代码如下所示。 - - ```Python - from functools import wraps - - - def coroutine(fn): - - @wraps(fn) - def wrapper(*args, **kwargs): - gen = fn(*args, **kwargs) - next(gen) - return gen - - return wrapper - ``` - - 这样就可以使用`@coroutine`装饰器对协程进行预激操作,不需要再写重复代码来激活协程。 - -3. 异步I/O - 非阻塞式I/O操作。 - - ```Python - import asyncio - - - @asyncio.coroutine - def countdown(name, n): - while n > 0: - print(f'Countdown[{name}]: {n}') - yield from asyncio.sleep(1) - n -= 1 - - - def main(): - loop = asyncio.get_event_loop() - tasks = [ - countdown("A", 10), countdown("B", 5), - ] - loop.run_until_complete(asyncio.wait(tasks)) - loop.close() - - - if __name__ == '__main__': - main() - ``` - -4. `async`和`await`。 - - ```Python - import asyncio - import aiohttp - - - async def download(url): - print('Fetch:', url) - async with aiohttp.ClientSession() as session: - async with session.get(url) as resp: - print(url, '--->', resp.status) - print(url, '--->', resp.cookies) - print('\n\n', await resp.text()) - - - def main(): - loop = asyncio.get_event_loop() - urls = [ - 'https://www.baidu.com', - 'http://www.sohu.com/', - 'http://www.sina.com.cn/', - 'https://www.taobao.com/', - 'https://www.jd.com/' - ] - tasks = [download(url) for url in urls] - loop.run_until_complete(asyncio.wait(tasks)) - loop.close() - - - if __name__ == '__main__': - main() - ``` - - 上面的代码使用了[AIOHTTP](https://github.com/aio-libs/aiohttp)这个非常著名的第三方库,它实现了HTTP客户端和HTTP服务器的功能,对异步操作提供了非常好的支持,有兴趣可以阅读它的[官方文档](https://aiohttp.readthedocs.io/en/stable/)。 +if __name__ == '__main__': + main() +``` ### 实例 - 多线程爬取“手机搜狐网”所有页面 diff --git a/Day66-75/70.解析动态内容.md b/Day61-65/65.解析动态内容.md similarity index 66% rename from Day66-75/70.解析动态内容.md rename to Day61-65/65.解析动态内容.md index 537b815..7c048d6 100644 --- a/Day66-75/70.解析动态内容.md +++ b/Day61-65/65.解析动态内容.md @@ -14,8 +14,6 @@ 那么结论就很简单了,只要我们找到了这些网络API接口,那么就能通过这些接口获取到数据,当然实际开发的时候可能还要对这些接口的参数以及接口返回的数据进行分析,了解每个参数的意义以及返回的JSON数据的格式,这样才能在我们的爬虫中使用这些数据。 -关于如何从网络API中获取JSON格式的数据并提取出我们需要的内容,在之前的[《文件和异常》](../Day01-15/Day11/文件和异常.md)一文中已经讲解过了,这里不再进行赘述。 - ### 使用Selenium 尽管很多网站对自己的网络API接口进行了保护,增加了获取数据的难度,但是只要经过足够的努力,绝大多数还是可以被逆向工程的,但是在实际开发中,我们可以通过浏览器渲染引擎来避免这些繁琐的工作,WebKit就是一个利用的渲染引擎。 @@ -79,4 +77,82 @@ selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executabl export PATH=$PATH:/Users/Hao/Downloads/Tools/chromedriver/ ``` -其中`/Users/Hao/Downloads/Tools/chromedriver/ `就是chromedriver所在的路径。 +其中`/Users/Hao/Downloads/Tools/chromedriver/ `就是chromedriver所在的路径。当然,更为简单的办法是把chromedriver直接放在虚拟环境中,跟Python解释器位于同一个路径下就可以了。 + +### WebDriver用法详解 + +表1. 定位页面元素的方法 + + + +表2. WebDriver的常用属性 + +| 属性 | 描述 | +| --------------------- | ----------------------------- | +| current_url | 当前页面的URL | +| current_window_handle | 当前窗口的句柄(引用) | +| name | WebDriver实例底层浏览器的名称 | +| orientation | 当前设备的方向(横屏、竖屏) | +| page_source | 当前页面的源代码(动态内容) | +| title | 当前页面的标题 | +| window_handles | WebDriver打开的所有窗口的句柄 | + +表3. WebDriver的常用方法 + +| 方法 | 描述 | +| ----------------------------------- | -------------------------------------- | +| back() / forward() | 在浏览历史记录中后退/前进 | +| close() / quit() | 关闭当前浏览器窗口 / 退出WebDriver实例 | +| get(url) | 加载指定URL的页面到浏览器中 | +| maximize_window() | 将浏览器窗口最大化 | +| refresh() | 刷新当前页面 | +| switch_to_active_element() | 获得页面上得到焦点的元素 | +| switch_to_alert() | 把焦点切换至弹出的警告框 | +| set_page_load_timeout(time_to_wait) | 设置页面加载超时时间 | +| set_script_timeout(time_to_wait) | 设置JavaScript执行超时时间 | +| implicit_wait(time_to_wait) | 设置等待元素被找到或目标指令完成 | + +### WebElement用法 + +表1. WebElement常用属性 + +| | | +| ---- | ---- | +| | | +| | | +| | | + +表2. WebElement常用方法 + +| | | +| ---- | ---- | +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | +| | | + +### Select用法 + +### Alert用法 + +### 元素等待机制 + +#### 隐式等待 + +#### 显示等待 + +### 高级特性 + +#### 鼠标和键盘事件 + +#### 调用JavaScript + +#### 屏幕截图和录制 + +#### 操作Cookie + diff --git a/Day61-65/65.项目实战.md b/Day61-65/65.项目实战.md deleted file mode 100644 index dbbae84..0000000 --- a/Day61-65/65.项目实战.md +++ /dev/null @@ -1,2 +0,0 @@ -## 项目实战 - diff --git a/Day61-65/code/.gitkeep b/Day61-65/code/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Day66-75/code/asyncio01.py b/Day61-65/code/asyncio01.py similarity index 100% rename from Day66-75/code/asyncio01.py rename to Day61-65/code/asyncio01.py diff --git a/Day66-75/code/asyncio02.py b/Day61-65/code/asyncio02.py similarity index 100% rename from Day66-75/code/asyncio02.py rename to Day61-65/code/asyncio02.py diff --git a/Day66-75/code/coroutine01.py b/Day61-65/code/coroutine01.py similarity index 100% rename from Day66-75/code/coroutine01.py rename to Day61-65/code/coroutine01.py diff --git a/Day66-75/code/coroutine02.py b/Day61-65/code/coroutine02.py similarity index 100% rename from Day66-75/code/coroutine02.py rename to Day61-65/code/coroutine02.py diff --git a/Day41-55/code/shop_origin/cart/migrations/__init__.py b/Day61-65/code/douban/douban/__init__.py similarity index 100% rename from Day41-55/code/shop_origin/cart/migrations/__init__.py rename to Day61-65/code/douban/douban/__init__.py diff --git a/Day66-75/code/douban/douban/items.py b/Day61-65/code/douban/douban/items.py similarity index 100% rename from Day66-75/code/douban/douban/items.py rename to Day61-65/code/douban/douban/items.py diff --git a/Day66-75/code/douban/douban/middlewares.py b/Day61-65/code/douban/douban/middlewares.py similarity index 100% rename from Day66-75/code/douban/douban/middlewares.py rename to Day61-65/code/douban/douban/middlewares.py diff --git a/Day66-75/code/douban/douban/pipelines.py b/Day61-65/code/douban/douban/pipelines.py similarity index 100% rename from Day66-75/code/douban/douban/pipelines.py rename to Day61-65/code/douban/douban/pipelines.py diff --git a/Day66-75/code/douban/douban/settings.py b/Day61-65/code/douban/douban/settings.py similarity index 100% rename from Day66-75/code/douban/douban/settings.py rename to Day61-65/code/douban/douban/settings.py diff --git a/Day66-75/code/douban/douban/spiders/__init__.py b/Day61-65/code/douban/douban/spiders/__init__.py similarity index 100% rename from Day66-75/code/douban/douban/spiders/__init__.py rename to Day61-65/code/douban/douban/spiders/__init__.py diff --git a/Day66-75/code/douban/douban/spiders/movie.py b/Day61-65/code/douban/douban/spiders/movie.py similarity index 100% rename from Day66-75/code/douban/douban/spiders/movie.py rename to Day61-65/code/douban/douban/spiders/movie.py diff --git a/Day66-75/code/douban/scrapy.cfg b/Day61-65/code/douban/scrapy.cfg similarity index 100% rename from Day66-75/code/douban/scrapy.cfg rename to Day61-65/code/douban/scrapy.cfg diff --git a/Day66-75/code/example01.py b/Day61-65/code/example01.py similarity index 100% rename from Day66-75/code/example01.py rename to Day61-65/code/example01.py diff --git a/Day66-75/code/example02.py b/Day61-65/code/example02.py similarity index 100% rename from Day66-75/code/example02.py rename to Day61-65/code/example02.py diff --git a/Day66-75/code/example03.py b/Day61-65/code/example03.py similarity index 100% rename from Day66-75/code/example03.py rename to Day61-65/code/example03.py diff --git a/Day66-75/code/example04.py b/Day61-65/code/example04.py similarity index 100% rename from Day66-75/code/example04.py rename to Day61-65/code/example04.py diff --git a/Day66-75/code/example05.py b/Day61-65/code/example05.py similarity index 100% rename from Day66-75/code/example05.py rename to Day61-65/code/example05.py diff --git a/Day66-75/code/example06.py b/Day61-65/code/example06.py similarity index 100% rename from Day66-75/code/example06.py rename to Day61-65/code/example06.py diff --git a/Day66-75/code/example07.py b/Day61-65/code/example07.py similarity index 100% rename from Day66-75/code/example07.py rename to Day61-65/code/example07.py diff --git a/Day66-75/code/example08.py b/Day61-65/code/example08.py similarity index 100% rename from Day66-75/code/example08.py rename to Day61-65/code/example08.py diff --git a/Day66-75/code/example09.py b/Day61-65/code/example09.py similarity index 100% rename from Day66-75/code/example09.py rename to Day61-65/code/example09.py diff --git a/Day66-75/code/example10.py b/Day61-65/code/example10.py similarity index 100% rename from Day66-75/code/example10.py rename to Day61-65/code/example10.py diff --git a/Day66-75/code/example10a.py b/Day61-65/code/example10a.py similarity index 100% rename from Day66-75/code/example10a.py rename to Day61-65/code/example10a.py diff --git a/Day66-75/code/example11.py b/Day61-65/code/example11.py similarity index 100% rename from Day66-75/code/example11.py rename to Day61-65/code/example11.py diff --git a/Day66-75/code/example11a.py b/Day61-65/code/example11a.py similarity index 100% rename from Day66-75/code/example11a.py rename to Day61-65/code/example11a.py diff --git a/Day66-75/code/example12.py b/Day61-65/code/example12.py similarity index 100% rename from Day66-75/code/example12.py rename to Day61-65/code/example12.py diff --git a/Day66-75/code/generator01.py b/Day61-65/code/generator01.py similarity index 100% rename from Day66-75/code/generator01.py rename to Day61-65/code/generator01.py diff --git a/Day66-75/code/generator02.py b/Day61-65/code/generator02.py similarity index 100% rename from Day66-75/code/generator02.py rename to Day61-65/code/generator02.py diff --git a/Day61-65/code/guido.jpg b/Day61-65/code/guido.jpg new file mode 100644 index 0000000..a8f217c Binary files /dev/null and b/Day61-65/code/guido.jpg differ diff --git a/Day61-65/code/hello-tornado/chat_handlers.py b/Day61-65/code/hello-tornado/chat_handlers.py deleted file mode 100644 index 528d8a1..0000000 --- a/Day61-65/code/hello-tornado/chat_handlers.py +++ /dev/null @@ -1,44 +0,0 @@ -""" -handlers.py - 用户登录和聊天的处理器 -""" -import tornado.web -import tornado.websocket - -nicknames = set() -connections = {} - - -class LoginHandler(tornado.web.RequestHandler): - - def get(self): - self.render('login.html', hint='') - - def post(self): - nickname = self.get_argument('nickname') - if nickname in nicknames: - self.render('login.html', hint='昵称已被使用,请更换昵称') - self.set_secure_cookie('nickname', nickname) - self.render('chat.html') - - -class ChatHandler(tornado.websocket.WebSocketHandler): - - def open(self): - nickname = self.get_secure_cookie('nickname').decode() - nicknames.add(nickname) - for conn in connections.values(): - conn.write_message(f'~~~{nickname}进入了聊天室~~~') - connections[nickname] = self - - def on_message(self, message): - nickname = self.get_secure_cookie('nickname').decode() - for conn in connections.values(): - if conn is not self: - conn.write_message(f'{nickname}说:{message}') - - def on_close(self): - nickname = self.get_secure_cookie('nickname').decode() - del connections[nickname] - nicknames.remove(nickname) - for conn in connections.values(): - conn.write_message(f'~~~{nickname}离开了聊天室~~~') diff --git a/Day61-65/code/hello-tornado/chat_server.py b/Day61-65/code/hello-tornado/chat_server.py deleted file mode 100644 index 4985acd..0000000 --- a/Day61-65/code/hello-tornado/chat_server.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -chat_server.py - 聊天服务器 -""" -import os - -import tornado.web -import tornado.ioloop - -from chat_handlers import LoginHandler, ChatHandler - - -def main(): - app = tornado.web.Application( - handlers=[(r'/login', LoginHandler), (r'/chat', ChatHandler)], - template_path=os.path.join(os.path.dirname(__file__), 'templates'), - static_path=os.path.join(os.path.dirname(__file__), 'static'), - cookie_secret='MWM2MzEyOWFlOWRiOWM2MGMzZThhYTk0ZDNlMDA0OTU=', - ) - app.listen(8888) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example01.py b/Day61-65/code/hello-tornado/example01.py deleted file mode 100644 index 6005256..0000000 --- a/Day61-65/code/hello-tornado/example01.py +++ /dev/null @@ -1,36 +0,0 @@ -""" -example01.py - 五分钟上手Tornado -""" -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - -# 定义默认端口 -define('port', default=8000, type=int) - - -class MainHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - # 向客户端(浏览器)写入内容 - self.write('

    Hello, world!

    ') - - -def main(): - """主函数""" - # 解析命令行参数,例如: - # python example01.py --port 8888 - parse_command_line() - # 创建了Tornado框架中Application类的实例并指定handlers参数 - # Application实例代表了我们的Web应用,handlers代表了路由解析 - app = tornado.web.Application(handlers=[(r'/', MainHandler), ]) - # 指定了监听HTTP请求的TCP端口(默认8000,也可以通过命令行参数指定) - app.listen(options.port) - # 获取Tornado框架的IOLoop实例并启动它(默认启动asyncio的事件循环) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example02.py b/Day61-65/code/hello-tornado/example02.py deleted file mode 100644 index c9ff9c0..0000000 --- a/Day61-65/code/hello-tornado/example02.py +++ /dev/null @@ -1,77 +0,0 @@ -""" -example02.py - 路由解析 -""" -import os -import random - -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - - -# 定义默认端口 -define('port', default=8000, type=int) - - -class SayingHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - sayings = [ - '世上没有绝望的处境,只有对处境绝望的人', - '人生的道路在态度的岔口一分为二,从此通向成功或失败', - '所谓措手不及,不是说没有时间准备,而是有时间的时候没有准备', - '那些你认为不靠谱的人生里,充满你没有勇气做的事', - '在自己喜欢的时间里,按照自己喜欢的方式,去做自己喜欢做的事,这便是自由', - '有些人不属于自己,但是遇见了也弥足珍贵' - ] - # 渲染index.html模板页 - self.render('index.html', message=random.choice(sayings)) - - -class WeatherHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self, city): - # Tornado框架会自动处理百分号编码的问题 - weathers = { - '北京': {'temperature': '-4~4', 'pollution': '195 中度污染'}, - '成都': {'temperature': '3~9', 'pollution': '53 良'}, - '深圳': {'temperature': '20~25', 'pollution': '25 优'}, - '广州': {'temperature': '18~23', 'pollution': '56 良'}, - '上海': {'temperature': '6~8', 'pollution': '65 良'} - } - if city in weathers: - self.render('weather.html', city=city, weather=weathers[city]) - else: - self.render('index.html', message=f'没有{city}的天气信息') - - -class ErrorHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - # 重定向到指定的路径 - self.redirect('/saying') - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - # handlers是按列表中的顺序依次进行匹配的 - handlers=[ - (r'/saying/?', SayingHandler), - (r'/weather/([^/]{2,})/?', WeatherHandler), - (r'/.+', ErrorHandler), - ], - # 通过template_path参数设置模板页的路径 - template_path=os.path.join(os.path.dirname(__file__), 'templates') - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example03.py b/Day61-65/code/hello-tornado/example03.py deleted file mode 100644 index 16ff8e5..0000000 --- a/Day61-65/code/hello-tornado/example03.py +++ /dev/null @@ -1,75 +0,0 @@ -""" -example03.py - RequestHandler解析 -""" -import os -import re - -import tornado.ioloop -import tornado.web - -from tornado.options import define, options, parse_command_line - - -# 定义默认端口 -define('port', default=8000, type=int) - -users = {} - - -class User(object): - """用户""" - - def __init__(self, nickname, gender, birthday): - self.nickname = nickname - self.gender = gender - self.birthday = birthday - - -class MainHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - # 从Cookie中读取用户昵称 - nickname = self.get_cookie('nickname') - if nickname in users: - self.render('userinfo.html', user=users[nickname]) - else: - self.render('userform.html', hint='请填写个人信息') - - -class UserHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def post(self): - # 从表单参数中读取用户昵称、性别和生日信息 - nickname = self.get_body_argument('nickname').strip() - gender = self.get_body_argument('gender') - birthday = self.get_body_argument('birthday') - # 检查用户昵称是否有效 - if not re.fullmatch(r'\w{6,20}', nickname): - self.render('userform.html', hint='请输入有效的昵称') - elif nickname in users: - self.render('userform.html', hint='昵称已经被使用过') - else: - users[nickname] = User(nickname, gender, birthday) - # 将用户昵称写入Cookie并设置有效期为7天 - self.set_cookie('nickname', nickname, expires_days=7) - self.render('userinfo.html', user=users[nickname]) - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - handlers=[ - (r'/', MainHandler), - (r'/register', UserHandler), - ], - template_path=os.path.join(os.path.dirname(__file__), 'templates'), - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example04.py b/Day61-65/code/hello-tornado/example04.py deleted file mode 100644 index 7b9204c..0000000 --- a/Day61-65/code/hello-tornado/example04.py +++ /dev/null @@ -1,42 +0,0 @@ -""" -example04.py - 同步请求的例子 -""" -import json -import os - -import requests -import tornado.gen -import tornado.ioloop -import tornado.web -import tornado.websocket -import tornado.httpclient -from tornado.options import define, options, parse_command_line - -define('port', default=8888, type=int) - -REQ_URL = 'http://api.tianapi.com/guonei/' -API_KEY = '772a81a51ae5c780251b1f98ea431b84' - - -class MainHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - def get(self): - resp = requests.get(f'{REQ_URL}?key={API_KEY}') - newslist = json.loads(resp.text)['newslist'] - self.render('news.html', newslist=newslist) - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - handlers=[(r'/', MainHandler), ], - template_path=os.path.join(os.path.dirname(__file__), 'templates'), - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example05.py b/Day61-65/code/hello-tornado/example05.py deleted file mode 100644 index e2f6117..0000000 --- a/Day61-65/code/hello-tornado/example05.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -example05.py - 异步请求的例子 -""" -import aiohttp -import json -import os - -import tornado.gen -import tornado.ioloop -import tornado.web -import tornado.websocket -import tornado.httpclient -from tornado.options import define, options, parse_command_line - -define('port', default=8888, type=int) - -REQ_URL = 'http://api.tianapi.com/guonei/' -API_KEY = '772a81a51ae5c780251b1f98ea431b84' - - -class MainHandler(tornado.web.RequestHandler): - """自定义请求处理器""" - - async def get(self): - async with aiohttp.ClientSession() as session: - resp = await session.get(f'{REQ_URL}?key={API_KEY}') - json_str = await resp.text() - print(json_str) - newslist = json.loads(json_str)['newslist'] - self.render('news.html', newslist=newslist) - - -def main(): - """主函数""" - parse_command_line() - app = tornado.web.Application( - handlers=[(r'/', MainHandler), ], - template_path=os.path.join(os.path.dirname(__file__), 'templates'), - ) - app.listen(options.port) - tornado.ioloop.IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example06.py b/Day61-65/code/hello-tornado/example06.py deleted file mode 100644 index 7143351..0000000 --- a/Day61-65/code/hello-tornado/example06.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -example06.py - 异步操作MySQL -""" -import json - -import aiomysql -import tornado -import tornado.web - -from tornado.ioloop import IOLoop -from tornado.options import define, parse_command_line, options - -define('port', default=8888, type=int) - - -async def connect_mysql(): - return await aiomysql.connect( - host='120.77.222.217', - port=3306, - db='hrs', - charset='utf8', - use_unicode=True, - user='root', - password='123456', - ) - - -class HomeHandler(tornado.web.RequestHandler): - - async def get(self, no): - async with self.settings['mysql'].cursor(aiomysql.DictCursor) as cursor: - await cursor.execute("select * from tb_dept where dno=%s", (no, )) - if cursor.rowcount == 0: - self.finish(json.dumps({ - 'code': 20001, - 'mesg': f'没有编号为{no}的部门' - })) - return - row = await cursor.fetchone() - self.finish(json.dumps(row)) - - async def post(self, *args, **kwargs): - no = self.get_argument('no') - name = self.get_argument('name') - loc = self.get_argument('loc') - conn = self.settings['mysql'] - try: - async with conn.cursor() as cursor: - await cursor.execute('insert into tb_dept values (%s, %s, %s)', - (no, name, loc)) - await conn.commit() - except aiomysql.MySQLError: - self.finish(json.dumps({ - 'code': 20002, - 'mesg': '添加部门失败请确认部门信息' - })) - else: - self.set_status(201) - self.finish() - - -def make_app(config): - return tornado.web.Application( - handlers=[(r'/api/depts/(.*)', HomeHandler), ], - **config - ) - - -def main(): - parse_command_line() - app = make_app({ - 'debug': True, - 'mysql': IOLoop.current().run_sync(connect_mysql) - }) - app.listen(options.port) - IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example07.py b/Day61-65/code/hello-tornado/example07.py deleted file mode 100644 index e0d454c..0000000 --- a/Day61-65/code/hello-tornado/example07.py +++ /dev/null @@ -1,92 +0,0 @@ -""" -example07.py - 将非异步的三方库封装为异步调用 -""" -import asyncio -import concurrent -import json - -import tornado -import tornado.web -import pymysql - -from pymysql import connect -from pymysql.cursors import DictCursor - -from tornado.ioloop import IOLoop -from tornado.options import define, parse_command_line, options -from tornado.platform.asyncio import AnyThreadEventLoopPolicy - -define('port', default=8888, type=int) - - -def get_mysql_connection(): - return connect( - host='120.77.222.217', - port=3306, - db='hrs', - charset='utf8', - use_unicode=True, - user='root', - password='123456', - ) - - -class HomeHandler(tornado.web.RequestHandler): - executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) - - async def get(self, no): - return await self._get(no) - - @tornado.concurrent.run_on_executor - def _get(self, no): - con = get_mysql_connection() - try: - with con.cursor(DictCursor) as cursor: - cursor.execute("select * from tb_dept where dno=%s", (no, )) - if cursor.rowcount == 0: - self.finish(json.dumps({ - 'code': 20001, - 'mesg': f'没有编号为{no}的部门' - })) - return - row = cursor.fetchone() - self.finish(json.dumps(row)) - finally: - con.close() - - async def post(self, *args, **kwargs): - return await self._post(*args, **kwargs) - - @tornado.concurrent.run_on_executor - def _post(self, *args, **kwargs): - no = self.get_argument('no') - name = self.get_argument('name') - loc = self.get_argument('loc') - conn = get_mysql_connection() - try: - with conn.cursor() as cursor: - cursor.execute('insert into tb_dept values (%s, %s, %s)', - (no, name, loc)) - conn.commit() - except pymysql.MySQLError: - self.finish(json.dumps({ - 'code': 20002, - 'mesg': '添加部门失败请确认部门信息' - })) - else: - self.set_status(201) - self.finish() - - -def main(): - asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy()) - parse_command_line() - app = tornado.web.Application( - handlers=[(r'/api/depts/(.*)', HomeHandler), ] - ) - app.listen(options.port) - IOLoop.current().start() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example_of_aiohttp.py b/Day61-65/code/hello-tornado/example_of_aiohttp.py deleted file mode 100644 index 362f6ff..0000000 --- a/Day61-65/code/hello-tornado/example_of_aiohttp.py +++ /dev/null @@ -1,30 +0,0 @@ -import asyncio -import re - -import aiohttp - -PATTERN = re.compile(r'\(?P.*)\<\/title\>') - - -async def show_title(url): - async with aiohttp.ClientSession() as session: - resp = await session.get(url, ssl=False) - html = await resp.text() - print(PATTERN.search(html).group('title')) - - -def main(): - urls = ('https://www.python.org/', - 'https://git-scm.com/', - 'https://www.jd.com/', - 'https://www.taobao.com/', - 'https://www.douban.com/') - # asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - # 获取事件循环() - loop = asyncio.get_event_loop() - tasks = [show_title(url) for url in urls] - loop.run_until_complete(asyncio.wait(tasks)) - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example_of_asyncio.py b/Day61-65/code/hello-tornado/example_of_asyncio.py deleted file mode 100644 index 0851f38..0000000 --- a/Day61-65/code/hello-tornado/example_of_asyncio.py +++ /dev/null @@ -1,40 +0,0 @@ -import asyncio - - -async def fetch(host): - """从指定的站点抓取信息(协程函数)""" - print(f'Start fetching {host}\n') - # 跟服务器建立连接 - reader, writer = await asyncio.open_connection(host, 80) - # 构造请求行和请求头 - writer.write(b'GET / HTTP/1.1\r\n') - writer.write(f'Host: {host}\r\n'.encode()) - writer.write(b'\r\n') - # 清空缓存区(发送请求) - await writer.drain() - # 接收服务器的响应(读取响应行和响应头) - line = await reader.readline() - while line != b'\r\n': - print(line.decode().rstrip()) - line = await reader.readline() - print('\n') - writer.close() - - -def main(): - """主函数""" - urls = ('www.sohu.com', 'www.douban.com', 'www.163.com') - # 获取系统默认的事件循环 - loop = asyncio.get_event_loop() - # 用生成式语法构造一个包含多个协程对象的列表 - tasks = [fetch(url) for url in urls] - # 通过asyncio模块的wait函数将协程列表包装成Task(Future子类)并等待其执行完成 - # 通过事件循环的run_until_complete方法运行任务直到Future完成并返回它的结果 - futures = asyncio.wait(tasks) - print(futures, type(futures)) - loop.run_until_complete(futures) - loop.close() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example_of_coroutine.py b/Day61-65/code/hello-tornado/example_of_coroutine.py deleted file mode 100644 index 070dad2..0000000 --- a/Day61-65/code/hello-tornado/example_of_coroutine.py +++ /dev/null @@ -1,50 +0,0 @@ -""" -协程(coroutine)- 可以在需要时进行切换的相互协作的子程序 -""" -import asyncio - -from example_of_multiprocess import is_prime - - -def num_generator(m, n): - """指定范围的数字生成器""" - for num in range(m, n + 1): - print(f'generate number: {num}') - yield num - - -async def prime_filter(m, n): - """素数过滤器""" - primes = [] - for i in num_generator(m, n): - if is_prime(i): - print('Prime =>', i) - primes.append(i) - - await asyncio.sleep(0.001) - return tuple(primes) - - -async def square_mapper(m, n): - """平方映射器""" - squares = [] - for i in num_generator(m, n): - print('Square =>', i * i) - squares.append(i * i) - - await asyncio.sleep(0.001) - return squares - - -def main(): - """主函数""" - loop = asyncio.get_event_loop() - start, end = 1, 100 - futures = asyncio.gather(prime_filter(start, end), square_mapper(start, end)) - futures.add_done_callback(lambda x: print(x.result())) - loop.run_until_complete(futures) - loop.close() - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/example_of_multiprocess.py b/Day61-65/code/hello-tornado/example_of_multiprocess.py deleted file mode 100644 index bef4c0f..0000000 --- a/Day61-65/code/hello-tornado/example_of_multiprocess.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -用下面的命令运行程序并查看执行时间,例如: -time python3 example05.py -real 0m20.657s -user 1m17.749s -sys 0m0.158s -使用多进程后实际执行时间为20.657秒,而用户时间1分17.749秒约为实际执行时间的4倍 -这就证明我们的程序通过多进程使用了CPU的多核特性,而且这台计算机配置了4核的CPU -""" -import concurrent.futures -import math - -PRIMES = [ - 1116281, - 1297337, - 104395303, - 472882027, - 533000389, - 817504243, - 982451653, - 112272535095293, - 112582705942171, - 112272535095293, - 115280095190773, - 115797848077099, - 1099726899285419 -] * 5 - - -def is_prime(num): - """判断素数""" - assert num > 0 - if num % 2 == 0: - return False - for i in range(3, int(math.sqrt(num)) + 1, 2): - if num % i == 0: - return False - return num != 1 - - -def main(): - """主函数""" - with concurrent.futures.ProcessPoolExecutor() as executor: - for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)): - print('%d is prime: %s' % (number, prime)) - - -if __name__ == '__main__': - main() diff --git a/Day61-65/code/hello-tornado/requirements.txt b/Day61-65/code/hello-tornado/requirements.txt deleted file mode 100644 index 619660c..0000000 --- a/Day61-65/code/hello-tornado/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -aiohttp==3.5.4 -aiomysql==0.0.20 -asn1crypto==0.24.0 -async-timeout==3.0.1 -attrs==19.1.0 -certifi==2019.3.9 -cffi==1.12.2 -chardet==3.0.4 -cryptography==2.6.1 -idna==2.8 -multidict==4.5.2 -pycparser==2.19 -PyMySQL==0.9.2 -requests==2.21.0 -six==1.12.0 -tornado==5.1.1 -urllib3==1.24.1 -yarl==1.3.0 diff --git a/Day61-65/code/hello-tornado/templates/chat.html b/Day61-65/code/hello-tornado/templates/chat.html deleted file mode 100644 index d83fd5c..0000000 --- a/Day61-65/code/hello-tornado/templates/chat.html +++ /dev/null @@ -1,67 +0,0 @@ -<!-- chat.html --> -<!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="UTF-8"> - <title>Tornado聊天室 - - -

    聊天室

    -
    -
    - -
    -
    - - -
    -

    - 退出聊天室 -

    - - - - diff --git a/Day61-65/code/hello-tornado/templates/login.html b/Day61-65/code/hello-tornado/templates/login.html deleted file mode 100644 index 69d6c55..0000000 --- a/Day61-65/code/hello-tornado/templates/login.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - Tornado聊天室 - - - -
    -
    -

    进入聊天室

    -
    -

    {{hint}}

    -
    - - - -
    -
    -
    - - diff --git a/Day61-65/code/hello-tornado/templates/news.html b/Day61-65/code/hello-tornado/templates/news.html deleted file mode 100644 index 9665d6b..0000000 --- a/Day61-65/code/hello-tornado/templates/news.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - 新闻列表 - - -

    新闻列表

    -
    - {% for news in newslist %} -
    - -

    {{news['title']}}

    -
    - {% end %} - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/service/__init__.py b/Day61-65/code/image360/image360/__init__.py similarity index 100% rename from Day61-65/code/project_of_tornado/service/__init__.py rename to Day61-65/code/image360/image360/__init__.py diff --git a/Day66-75/code/image360/image360/items.py b/Day61-65/code/image360/image360/items.py similarity index 100% rename from Day66-75/code/image360/image360/items.py rename to Day61-65/code/image360/image360/items.py diff --git a/Day66-75/code/image360/image360/middlewares.py b/Day61-65/code/image360/image360/middlewares.py similarity index 96% rename from Day66-75/code/image360/image360/middlewares.py rename to Day61-65/code/image360/image360/middlewares.py index 13d9c46..10b3224 100644 --- a/Day66-75/code/image360/image360/middlewares.py +++ b/Day61-65/code/image360/image360/middlewares.py @@ -111,6 +111,9 @@ class TaobaoDownloaderMiddleWare(object): def __init__(self, timeout=None): self.timeout = timeout + # options = webdriver.ChromeOptions() + # options.add_argument('headless') + # self.browser = webdriver.Chrome(options=options) self.browser = webdriver.Chrome() self.browser.set_window_size(1000, 600) self.browser.set_page_load_timeout(self.timeout) diff --git a/Day66-75/code/image360/image360/pipelines.py b/Day61-65/code/image360/image360/pipelines.py similarity index 100% rename from Day66-75/code/image360/image360/pipelines.py rename to Day61-65/code/image360/image360/pipelines.py diff --git a/Day66-75/code/image360/image360/settings.py b/Day61-65/code/image360/image360/settings.py similarity index 96% rename from Day66-75/code/image360/image360/settings.py rename to Day61-65/code/image360/image360/settings.py index 76dbbfe..266eab4 100644 --- a/Day66-75/code/image360/image360/settings.py +++ b/Day61-65/code/image360/image360/settings.py @@ -71,10 +71,10 @@ IMAGES_STORE = './resources/' # Configure item pipelines # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html -# ITEM_PIPELINES = { -# 'image360.pipelines.SaveImagePipeline': 300, -# 'image360.pipelines.SaveToMongoPipeline': 301, -# } +ITEM_PIPELINES = { + 'image360.pipelines.SaveImagePipeline': 300, + 'image360.pipelines.SaveToMongoPipeline': 301, +} LOG_LEVEL = 'DEBUG' diff --git a/Day66-75/code/image360/image360/spiders/__init__.py b/Day61-65/code/image360/image360/spiders/__init__.py similarity index 100% rename from Day66-75/code/image360/image360/spiders/__init__.py rename to Day61-65/code/image360/image360/spiders/__init__.py diff --git a/Day66-75/code/image360/image360/spiders/image.py b/Day61-65/code/image360/image360/spiders/image.py similarity index 100% rename from Day66-75/code/image360/image360/spiders/image.py rename to Day61-65/code/image360/image360/spiders/image.py diff --git a/Day66-75/code/image360/image360/spiders/taobao.py b/Day61-65/code/image360/image360/spiders/taobao.py similarity index 100% rename from Day66-75/code/image360/image360/spiders/taobao.py rename to Day61-65/code/image360/image360/spiders/taobao.py diff --git a/Day66-75/code/image360/scrapy.cfg b/Day61-65/code/image360/scrapy.cfg similarity index 100% rename from Day66-75/code/image360/scrapy.cfg rename to Day61-65/code/image360/scrapy.cfg diff --git a/Day66-75/code/main.py b/Day61-65/code/main.py similarity index 100% rename from Day66-75/code/main.py rename to Day61-65/code/main.py diff --git a/Day66-75/code/main_redis.py b/Day61-65/code/main_redis.py similarity index 100% rename from Day66-75/code/main_redis.py rename to Day61-65/code/main_redis.py diff --git a/Day66-75/code/myutils.py b/Day61-65/code/myutils.py similarity index 100% rename from Day66-75/code/myutils.py rename to Day61-65/code/myutils.py diff --git a/Day61-65/code/project_of_tornado/assets/css/admin.css b/Day61-65/code/project_of_tornado/assets/css/admin.css deleted file mode 100644 index 3fd52e0..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/admin.css +++ /dev/null @@ -1,373 +0,0 @@ -/** - * admin.css - */ - - -/* - fixed-layout 固定头部和边栏布局 -*/ - -html, -body { - height: 100%; - overflow: hidden; -} - -ul { - margin-top: 0; -} - -.admin-icon-yellow { - color: #ffbe40; -} - -.admin-header { - position: fixed; - top: 0; - left: 0; - right: 0; - z-index: 1500; - font-size: 1.4rem; - margin-bottom: 0; -} - -.admin-header-list a:hover :after { - content: none; -} - -.admin-main { - position: relative; - height: 100%; - padding-top: 51px; - background: #f3f3f3; -} - -.admin-menu { - position: fixed; - z-index: 10; - bottom: 30px; - right: 20px; -} - -.admin-sidebar { - width: 260px; - min-height: 100%; - float: left; - border-right: 1px solid #cecece; -} - -.admin-sidebar.am-active { - z-index: 1600; -} - -.admin-sidebar-list { - margin-bottom: 0; -} - -.admin-sidebar-list li a { - color: #5c5c5c; - padding-left: 24px; -} - -.admin-sidebar-list li:first-child { - border-top: none; -} - -.admin-sidebar-sub { - margin-top: 0; - margin-bottom: 0; - box-shadow: 0 16px 8px -15px #e2e2e2 inset; - background: #ececec; - padding-left: 24px; -} - -.admin-sidebar-sub li:first-child { - border-top: 1px solid #dedede; -} - -.admin-sidebar-panel { - margin: 10px; -} - -.admin-content { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - background: #fff; -} - -.admin-content, -.admin-sidebar { - height: 100%; - overflow-x: hidden; - overflow-y: scroll; - -webkit-overflow-scrolling: touch; -} - -.admin-content-body { - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; -} - -.admin-content-footer { - font-size: 85%; - color: #777; -} - -.admin-content-list { - border: 1px solid #e9ecf1; - margin-top: 0; -} - -.admin-content-list li { - border: 1px solid #e9ecf1; - border-width: 0 1px; - margin-left: -1px; -} - -.admin-content-list li:first-child { - border-left: none; -} - -.admin-content-list li:last-child { - border-right: none; -} - -.admin-content-table a { - color: #535353; -} -.admin-content-file { - margin-bottom: 0; - color: #666; -} - -.admin-content-file p { - margin: 0 0 5px 0; - font-size: 1.4rem; -} - -.admin-content-file li { - padding: 10px 0; -} - -.admin-content-file li:first-child { - border-top: none; -} - -.admin-content-file li:last-child { - border-bottom: none; -} - -.admin-content-file li .am-progress { - margin-bottom: 4px; -} - -.admin-content-file li .am-progress-bar { - line-height: 14px; -} - -.admin-content-task { - margin-bottom: 0; -} - -.admin-content-task li { - padding: 5px 0; - border-color: #eee; -} - -.admin-content-task li:first-child { - border-top: none; -} - -.admin-content-task li:last-child { - border-bottom: none; -} - -.admin-task-meta { - font-size: 1.2rem; - color: #999; -} - -.admin-task-bd { - font-size: 1.4rem; - margin-bottom: 5px; -} - -.admin-content-comment { - margin-bottom: 0; -} - -.admin-content-comment .am-comment-bd { - font-size: 1.4rem; -} - -.admin-content-pagination { - margin-bottom: 0; -} -.admin-content-pagination li a { - padding: 4px 8px; -} - -@media only screen and (min-width: 641px) { - .admin-sidebar { - display: block; - position: static; - background: none; - } - - .admin-offcanvas-bar { - position: static; - width: auto; - background: none; - -webkit-transform: translate3d(0, 0, 0); - -ms-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); - overflow-y: visible; - min-height: 100%; - } - .admin-offcanvas-bar:after { - content: none; - } -} - -@media only screen and (max-width: 640px) { - .admin-sidebar { - width: inherit; - } - - .admin-offcanvas-bar { - background: #f3f3f3; - } - - .admin-offcanvas-bar:after { - background: #BABABA; - } - - .admin-sidebar-list a:hover, .admin-sidebar-list a:active{ - -webkit-transition: background-color .3s ease; - -moz-transition: background-color .3s ease; - -ms-transition: background-color .3s ease; - -o-transition: background-color .3s ease; - transition: background-color .3s ease; - background: #E4E4E4; - } - - .admin-content-list li { - padding: 10px; - border-width: 1px 0; - margin-top: -1px; - } - - .admin-content-list li:first-child { - border-top: none; - } - - .admin-content-list li:last-child { - border-bottom: none; - } - - .admin-form-text { - text-align: left !important; - } - -} - -/* -* user.html css -*/ -.user-info { - margin-bottom: 15px; -} - -.user-info .am-progress { - margin-bottom: 4px; -} - -.user-info p { - margin: 5px; -} - -.user-info-order { - font-size: 1.4rem; -} - -/* -* errorLog.html css -*/ - -.error-log .am-pre-scrollable { - max-height: 40rem; -} - -/* -* table.html css -*/ - -.table-main { - font-size: 1.4rem; - padding: .5rem; -} - -.table-main button { - background: #fff; -} - -.table-check { - width: 30px; -} - -.table-id { - width: 50px; -} - -@media only screen and (max-width: 640px) { - .table-select { - margin-top: 10px; - margin-left: 5px; - } -} - -/* -gallery.html css -*/ - -.gallery-list li { - padding: 10px; -} - -.gallery-list a { - color: #666; -} - -.gallery-list a:hover { - color: #3bb4f2; -} - -.gallery-title { - margin-top: 6px; - font-size: 1.4rem; -} - -.gallery-desc { - font-size: 1.2rem; - margin-top: 4px; -} - -/* - 404.html css -*/ - -.page-404 { - background: #fff; - border: none; - width: 200px; - margin: 0 auto; -} diff --git a/Day61-65/code/project_of_tornado/assets/css/amazeui.datatables.min.css b/Day61-65/code/project_of_tornado/assets/css/amazeui.datatables.min.css deleted file mode 100644 index f579a99..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/amazeui.datatables.min.css +++ /dev/null @@ -1 +0,0 @@ -.am-datatable-hd{margin-bottom:10px}.am-datatable-hd label{font-weight:400}.am-datatable-filter{text-align:right}.am-datatable-filter input{margin-left:.5em}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_desc_disabled{cursor:pointer;position:relative}table.dataTable thead .sorting:after{position:absolute;top:50%;margin-top:-12px;right:8px;display:block;font-weight:400}table.dataTable thead .sorting_asc:after,table.dataTable thead .sorting_desc:after{position:absolute;top:50%;margin-top:-12px;right:8px;display:block;opacity:.5;font-weight:400}table.dataTable thead .sorting:after{opacity:.2;content:"\f0dc"}table.dataTable thead .sorting_asc:after{content:"\f15d"}table.dataTable thead .sorting_desc:after{content:"\f15e"}div.DTFC_LeftBodyWrapper table.dataTable thead .sorting:after,div.DTFC_LeftBodyWrapper table.dataTable thead .sorting_asc:after,div.DTFC_LeftBodyWrapper table.dataTable thead .sorting_desc:after,div.DTFC_RightBodyWrapper table.dataTable thead .sorting:after,div.DTFC_RightBodyWrapper table.dataTable thead .sorting_asc:after,div.DTFC_RightBodyWrapper table.dataTable thead .sorting_desc:after,div.dataTables_scrollBody table.dataTable thead .sorting:after,div.dataTables_scrollBody table.dataTable thead .sorting_asc:after,div.dataTables_scrollBody table.dataTable thead .sorting_desc:after{display:none}table.dataTable thead .sorting_asc_disabled:after,table.dataTable thead .sorting_desc_disabled:after{color:#eee}table.dataTable thead>tr>th{padding-right:30px}table.dataTable th:active{outline:none}table.dataTable.table-condensed thead>tr>th{padding-right:20px}table.dataTable.table-condensed thead .sorting:after,table.dataTable.table-condensed thead .sorting_asc:after,table.dataTable.table-condensed thead .sorting_desc:after{top:6px;right:6px}div.dataTables_scrollHead table{margin-bottom:0!important;border-bottom-left-radius:0;border-bottom-right-radius:0}div.DTFC_LeftHeadWrapper table thead tr:last-child td:first-child,div.DTFC_LeftHeadWrapper table thead tr:last-child th:first-child,div.DTFC_RightHeadWrapper table thead tr:last-child td:first-child,div.DTFC_RightHeadWrapper table thead tr:last-child th:first-child,div.dataTables_scrollHead table thead tr:last-child td:first-child,div.dataTables_scrollHead table thead tr:last-child th:first-child{border-bottom-left-radius:0!important;border-bottom-right-radius:0!important}div.dataTables_scrollBody table{border-top:none;margin-top:0!important;margin-bottom:0!important}div.DTFC_LeftBodyWrapper tbody tr:first-child td,div.DTFC_LeftBodyWrapper tbody tr:first-child th,div.DTFC_RightBodyWrapper tbody tr:first-child td,div.DTFC_RightBodyWrapper tbody tr:first-child th,div.dataTables_scrollBody tbody tr:first-child td,div.dataTables_scrollBody tbody tr:first-child th{border-top:none}div.dataTables_scrollFoot table{margin-top:0!important;border-top:none}table.table-bordered.dataTable{border-collapse:separate!important}table.table-bordered thead td,table.table-bordered thead th{border-left-width:0;border-top-width:0}table.table-bordered tbody td,table.table-bordered tbody th,table.table-bordered tfoot td,table.table-bordered tfoot th{border-left-width:0;border-bottom-width:0}table.table-bordered td:last-child,table.table-bordered th:last-child{border-right-width:0}div.dataTables_scrollHead table.table-bordered{border-bottom-width:0}.table.dataTable tbody tr.active td,.table.dataTable tbody tr.active th{background-color:#08c;color:#fff}.table.dataTable tbody tr.active:hover td,.table.dataTable tbody tr.active:hover th{background-color:#0075b0!important}.table.dataTable tbody tr.active td>a,.table.dataTable tbody tr.active th>a{color:#fff}.table-striped.dataTable tbody tr.active:nth-child(odd) td,.table-striped.dataTable tbody tr.active:nth-child(odd) th{background-color:#017ebc}table.DTTT_selectable tbody tr{cursor:pointer}div.DTTT .btn:hover{text-decoration:none!important}ul.DTTT_dropdown.dropdown-menu{z-index:2003}ul.DTTT_dropdown.dropdown-menu a{color:#333!important}ul.DTTT_dropdown.dropdown-menu li{position:relative}ul.DTTT_dropdown.dropdown-menu li:hover a{background-color:#08c;color:#fff!important}div.DTTT_collection_background{z-index:2002}div.DTTT_print_info,div.dataTables_processing{top:50%;left:50%;text-align:center;background-color:#fff}div.DTTT_print_info{color:#333;padding:10px 30px;opacity:.95;border:1px solid rgba(0,0,0,.2);border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,.5);box-shadow:0 3px 7px rgba(0,0,0,.5);position:fixed;width:400px;height:150px;margin-left:-200px;margin-top:-75px}div.DTTT_print_info h6{font-weight:400;font-size:28px;line-height:28px;margin:1em}div.DTTT_print_info p{font-size:14px;line-height:20px}div.dataTables_processing{position:absolute;width:100%;height:60px;margin-left:-50%;margin-top:-25px;padding-top:20px;padding-bottom:20px;font-size:1.2em;background:-webkit-gradient(linear,left top,right top,color-stop(0%,rgba(255,255,255,0)),color-stop(25%,rgba(255,255,255,.9)),color-stop(75%,rgba(255,255,255,.9)),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0%,rgba(255,255,255,.9) 25%,rgba(255,255,255,.9) 75%,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,from(rgba(255,255,255,0)),color-stop(25%,rgba(255,255,255,.9)),color-stop(75%,rgba(255,255,255,.9)),to(rgba(255,255,255,0)));background:linear-gradient(to right,rgba(255,255,255,0) 0%,rgba(255,255,255,.9) 25%,rgba(255,255,255,.9) 75%,rgba(255,255,255,0) 100%)}div.DTFC_LeftHeadWrapper table{background-color:#fff}div.DTFC_LeftFootWrapper table{background-color:#fff;margin-bottom:0}div.DTFC_RightHeadWrapper table{background-color:#fff}div.DTFC_RightFootWrapper table,table.DTFC_Cloned tr.even{background-color:#fff;margin-bottom:0}div.DTFC_LeftHeadWrapper table,div.DTFC_RightHeadWrapper table{border-bottom:none!important;margin-bottom:0!important;border-top-right-radius:0!important;border-bottom-left-radius:0!important;border-bottom-right-radius:0!important}div.DTFC_LeftBodyWrapper table,div.DTFC_RightBodyWrapper table{border-top:none;margin:0!important}div.DTFC_LeftFootWrapper table,div.DTFC_RightFootWrapper table{border-top:none;margin-top:0!important}div.FixedHeader_Cloned table{margin:0!important}.am-datatable-pager{margin-top:0;margin-bottom:0}.am-datatable-info{padding-top:6px;color:#555;font-size:1.4rem}table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child,table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child{position:relative;padding-left:30px;cursor:pointer}table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child:before{top:8px;left:4px;height:16px;width:16px;display:block;position:absolute;color:#fff;border:2px solid #fff;border-radius:16px;text-align:center;line-height:14px;-webkit-box-shadow:0 0 3px #444;box-shadow:0 0 3px #444;-webkit-box-sizing:content-box;box-sizing:content-box;content:'+';background-color:#31b131}table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child.dataTables_empty:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child.dataTables_empty:before{display:none}table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td:first-child:before,table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th:first-child:before{content:'-';background-color:#d33333}table.dataTable.dtr-inline.collapsed>tbody>tr.child td:before{display:none}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td:first-child,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th:first-child{padding-left:27px}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td:first-child:before,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th:first-child:before{top:5px;left:4px;height:14px;width:14px;border-radius:14px;line-height:12px}table.dataTable.dtr-column>tbody>tr>td.control,table.dataTable.dtr-column>tbody>tr>th.control{position:relative;cursor:pointer}table.dataTable.dtr-column>tbody>tr>td.control:before,table.dataTable.dtr-column>tbody>tr>th.control:before{top:50%;left:50%;height:16px;width:16px;margin-top:-10px;margin-left:-10px;display:block;position:absolute;color:#fff;border:2px solid #fff;border-radius:16px;text-align:center;line-height:14px;-webkit-box-shadow:0 0 3px #666;box-shadow:0 0 3px #666;-webkit-box-sizing:content-box;box-sizing:content-box;content:'+';background-color:#5eb95e}table.dataTable.dtr-column>tbody>tr.parent td.control:before,table.dataTable.dtr-column>tbody>tr.parent th.control:before{content:'-';background-color:#dd514c}table.dataTable>tbody>tr.child{padding:.5em 1em}table.dataTable>tbody>tr.child:hover{background:0 0!important}table.dataTable>tbody>tr.child ul{display:inline-block;list-style-type:none;margin:0;padding:0}table.dataTable>tbody>tr.child ul li{border-bottom:1px solid #efefef;padding:.5em 0}table.dataTable>tbody>tr.child ul li:first-child{padding-top:0}table.dataTable>tbody>tr.child ul li:last-child{border-bottom:none}table.dataTable>tbody>tr.child span.dtr-title{display:inline-block;min-width:75px;font-weight:700} \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/css/amazeui.min.css b/Day61-65/code/project_of_tornado/assets/css/amazeui.min.css deleted file mode 100644 index 39263eb..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/amazeui.min.css +++ /dev/null @@ -1 +0,0 @@ -/*! Amaze UI v2.7.2 | by Amaze UI Team | (c) 2016 AllMobilize, Inc. | Licensed under MIT | 2016-08-17T16:17:24+0800 */*,:after,:before{-webkit-box-sizing:border-box;box-sizing:border-box}body,html{min-height:100%}html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],script,template{display:none}a{background-color:transparent}a:focus{outline:thin dotted}a:active,a:hover{outline:0}a,ins{text-decoration:none}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}pre{white-space:pre-wrap}q{quotes:"\201C" "\201D" "\2018" "\2019"}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{-webkit-box-sizing:border-box;box-sizing:border-box;vertical-align:middle;border:0}svg:not(:root){overflow:hidden}figure{margin:0}code,kbd,pre,samp{font-family:Monaco,Menlo,Consolas,"Courier New",FontAwesome,monospace;font-size:1em}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,input{line-height:normal}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}input[type=checkbox],input[type=radio]{cursor:pointer;padding:0;-webkit-box-sizing:border-box;box-sizing:border-box}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top;resize:vertical}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{position:relative;background:#fff;font-family:"Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif;font-weight:400;line-height:1.6;color:#333;font-size:1.6rem}body,button,input,select,textarea{text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-font-feature-settings:"liga","kern"}@media only screen and (max-width:640px){body{word-wrap:break-word;-webkit-hyphens:auto;-ms-hyphens:auto;-moz-hyphens:auto;hyphens:auto}}a{color:#0e90d2}a:focus,a:hover{color:#095f8a}a:focus{outline:thin dotted;outline:1px auto -webkit-focus-ring-color;outline-offset:-2px}ins{background:#ffa;color:#333}mark{background:#ffa;color:#333}abbr[title],dfn[title]{cursor:help}dfn[title]{border-bottom:1px dotted;font-style:normal}address,blockquote,dl,fieldset,figure,hr,ol,p,pre,ul{margin:0 0 1.6rem 0}*+address,*+blockquote,*+dl,*+fieldset,*+figure,*+hr,*+ol,*+p,*+pre,*+ul{margin-top:1.6rem}h1,h2,h3,h4,h5,h6{margin:0 0 1.6rem 0;font-weight:600;font-size:100%}h1{font-size:1.5em}h2{font-size:1.25em}*+h1,*+h2,*+h3,*+h4,*+h5,*+h6{margin-top:2em}ol,ul{padding-left:2em}ol>li>ol,ol>li>ul,ul>li>ol,ul>li>ul{margin:1em 0}dt{font-weight:700}dt+dd{margin-top:.5em}dd{margin-left:0}dd+dt{margin-top:1em}hr{display:block;padding:0;border:0;height:0;border-top:1px solid #eee;-webkit-box-sizing:content-box;box-sizing:content-box}address{font-style:normal}blockquote{padding-top:5px;padding-bottom:5px;padding-left:15px;border-left:4px solid #ddd;font-family:Georgia,"Times New Roman",Times,Kai,"Kaiti SC",KaiTi,BiauKai,FontAwesome,serif}blockquote small{display:block;color:#999;font-family:"Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif;text-align:right}blockquote p:last-of-type{margin-bottom:0}iframe{border:0}button,input:not([type=radio]):not([type=checkbox]),select{vertical-align:middle}.am-scrollbar-measure{width:100px;height:100px;overflow:scroll;position:absolute;top:-9999px}.am-container{-webkit-box-sizing:border-box;box-sizing:border-box;margin-left:auto;margin-right:auto;padding-left:1rem;padding-right:1rem;width:100%;max-width:1000px}.am-container:after,.am-container:before{content:" ";display:table}.am-container:after{clear:both}@media only screen and (min-width:641px){.am-container{padding-left:1.5rem;padding-right:1.5rem}}.am-container>.am-g{width:auto;margin-left:-1rem;margin-right:-1rem}@media only screen and (min-width:641px){.am-container>.am-g{margin-left:-1.5rem;margin-right:-1.5rem}}.am-g{margin:0 auto;width:100%}.am-g:after,.am-g:before{content:" ";display:table}.am-g:after{clear:both}.am-g .am-g{margin-left:-1rem;margin-right:-1rem;width:auto}.am-g .am-g.am-g-collapse{margin-left:0;margin-right:0;width:auto}@media only screen and (min-width:641px){.am-g .am-g{margin-left:-1.5rem;margin-right:-1.5rem}}.am-g.am-g-collapse .am-g{margin-left:0;margin-right:0}.am-g-collapse [class*=am-u-]{padding-left:0;padding-right:0}.am-g-fixed{max-width:1000px}[class*=am-u-]{width:100%;padding-left:1rem;padding-right:1rem;float:left;position:relative}[class*=am-u-]+[class*=am-u-]:last-child{float:right}[class*=am-u-]+[class*=am-u-].am-u-end{float:left}@media only screen and (min-width:641px){[class*=am-u-]{padding-left:1.5rem;padding-right:1.5rem}}[class*=am-u-pull-]{left:auto}[class*=am-u-push-]{right:auto}@media only screen{.am-u-sm-1{width:8.33333333%}.am-u-sm-2{width:16.66666667%}.am-u-sm-3{width:25%}.am-u-sm-4{width:33.33333333%}.am-u-sm-5{width:41.66666667%}.am-u-sm-6{width:50%}.am-u-sm-7{width:58.33333333%}.am-u-sm-8{width:66.66666667%}.am-u-sm-9{width:75%}.am-u-sm-10{width:83.33333333%}.am-u-sm-11{width:91.66666667%}.am-u-sm-12{width:100%}.am-u-sm-pull-0{right:0}.am-u-sm-pull-1{right:8.33333333%}.am-u-sm-pull-2{right:16.66666667%}.am-u-sm-pull-3{right:25%}.am-u-sm-pull-4{right:33.33333333%}.am-u-sm-pull-5{right:41.66666667%}.am-u-sm-pull-6{right:50%}.am-u-sm-pull-7{right:58.33333333%}.am-u-sm-pull-8{right:66.66666667%}.am-u-sm-pull-9{right:75%}.am-u-sm-pull-10{right:83.33333333%}.am-u-sm-pull-11{right:91.66666667%}.am-u-sm-push-0{left:0}.am-u-sm-push-1{left:8.33333333%}.am-u-sm-push-2{left:16.66666667%}.am-u-sm-push-3{left:25%}.am-u-sm-push-4{left:33.33333333%}.am-u-sm-push-5{left:41.66666667%}.am-u-sm-push-6{left:50%}.am-u-sm-push-7{left:58.33333333%}.am-u-sm-push-8{left:66.66666667%}.am-u-sm-push-9{left:75%}.am-u-sm-push-10{left:83.33333333%}.am-u-sm-push-11{left:91.66666667%}.am-u-sm-offset-0{margin-left:0}.am-u-sm-offset-1{margin-left:8.33333333%}.am-u-sm-offset-2{margin-left:16.66666667%}.am-u-sm-offset-3{margin-left:25%}.am-u-sm-offset-4{margin-left:33.33333333%}.am-u-sm-offset-5{margin-left:41.66666667%}.am-u-sm-offset-6{margin-left:50%}.am-u-sm-offset-7{margin-left:58.33333333%}.am-u-sm-offset-8{margin-left:66.66666667%}.am-u-sm-offset-9{margin-left:75%}.am-u-sm-offset-10{margin-left:83.33333333%}.am-u-sm-offset-11{margin-left:91.66666667%}.am-u-sm-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}[class*=am-u-].am-u-sm-centered{margin-left:auto;margin-right:auto;float:none}[class*=am-u-].am-u-sm-centered:last-child{float:none}[class*=am-u-].am-u-sm-uncentered{margin-left:0;margin-right:0;float:left}[class*=am-u-].am-u-sm-uncentered:last-child{float:left}}@media only screen and (min-width:641px){.am-u-md-1{width:8.33333333%}.am-u-md-2{width:16.66666667%}.am-u-md-3{width:25%}.am-u-md-4{width:33.33333333%}.am-u-md-5{width:41.66666667%}.am-u-md-6{width:50%}.am-u-md-7{width:58.33333333%}.am-u-md-8{width:66.66666667%}.am-u-md-9{width:75%}.am-u-md-10{width:83.33333333%}.am-u-md-11{width:91.66666667%}.am-u-md-12{width:100%}.am-u-md-pull-0{right:0}.am-u-md-pull-1{right:8.33333333%}.am-u-md-pull-2{right:16.66666667%}.am-u-md-pull-3{right:25%}.am-u-md-pull-4{right:33.33333333%}.am-u-md-pull-5{right:41.66666667%}.am-u-md-pull-6{right:50%}.am-u-md-pull-7{right:58.33333333%}.am-u-md-pull-8{right:66.66666667%}.am-u-md-pull-9{right:75%}.am-u-md-pull-10{right:83.33333333%}.am-u-md-pull-11{right:91.66666667%}.am-u-md-push-0{left:0}.am-u-md-push-1{left:8.33333333%}.am-u-md-push-2{left:16.66666667%}.am-u-md-push-3{left:25%}.am-u-md-push-4{left:33.33333333%}.am-u-md-push-5{left:41.66666667%}.am-u-md-push-6{left:50%}.am-u-md-push-7{left:58.33333333%}.am-u-md-push-8{left:66.66666667%}.am-u-md-push-9{left:75%}.am-u-md-push-10{left:83.33333333%}.am-u-md-push-11{left:91.66666667%}.am-u-md-offset-0{margin-left:0}.am-u-md-offset-1{margin-left:8.33333333%}.am-u-md-offset-2{margin-left:16.66666667%}.am-u-md-offset-3{margin-left:25%}.am-u-md-offset-4{margin-left:33.33333333%}.am-u-md-offset-5{margin-left:41.66666667%}.am-u-md-offset-6{margin-left:50%}.am-u-md-offset-7{margin-left:58.33333333%}.am-u-md-offset-8{margin-left:66.66666667%}.am-u-md-offset-9{margin-left:75%}.am-u-md-offset-10{margin-left:83.33333333%}.am-u-md-offset-11{margin-left:91.66666667%}.am-u-md-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}[class*=am-u-].am-u-md-centered{margin-left:auto;margin-right:auto;float:none}[class*=am-u-].am-u-md-centered:last-child{float:none}[class*=am-u-].am-u-md-uncentered{margin-left:0;margin-right:0;float:left}[class*=am-u-].am-u-md-uncentered:last-child{float:left}}@media only screen and (min-width:1025px){.am-u-lg-1{width:8.33333333%}.am-u-lg-2{width:16.66666667%}.am-u-lg-3{width:25%}.am-u-lg-4{width:33.33333333%}.am-u-lg-5{width:41.66666667%}.am-u-lg-6{width:50%}.am-u-lg-7{width:58.33333333%}.am-u-lg-8{width:66.66666667%}.am-u-lg-9{width:75%}.am-u-lg-10{width:83.33333333%}.am-u-lg-11{width:91.66666667%}.am-u-lg-12{width:100%}.am-u-lg-pull-0{right:0}.am-u-lg-pull-1{right:8.33333333%}.am-u-lg-pull-2{right:16.66666667%}.am-u-lg-pull-3{right:25%}.am-u-lg-pull-4{right:33.33333333%}.am-u-lg-pull-5{right:41.66666667%}.am-u-lg-pull-6{right:50%}.am-u-lg-pull-7{right:58.33333333%}.am-u-lg-pull-8{right:66.66666667%}.am-u-lg-pull-9{right:75%}.am-u-lg-pull-10{right:83.33333333%}.am-u-lg-pull-11{right:91.66666667%}.am-u-lg-push-0{left:0}.am-u-lg-push-1{left:8.33333333%}.am-u-lg-push-2{left:16.66666667%}.am-u-lg-push-3{left:25%}.am-u-lg-push-4{left:33.33333333%}.am-u-lg-push-5{left:41.66666667%}.am-u-lg-push-6{left:50%}.am-u-lg-push-7{left:58.33333333%}.am-u-lg-push-8{left:66.66666667%}.am-u-lg-push-9{left:75%}.am-u-lg-push-10{left:83.33333333%}.am-u-lg-push-11{left:91.66666667%}.am-u-lg-offset-0{margin-left:0}.am-u-lg-offset-1{margin-left:8.33333333%}.am-u-lg-offset-2{margin-left:16.66666667%}.am-u-lg-offset-3{margin-left:25%}.am-u-lg-offset-4{margin-left:33.33333333%}.am-u-lg-offset-5{margin-left:41.66666667%}.am-u-lg-offset-6{margin-left:50%}.am-u-lg-offset-7{margin-left:58.33333333%}.am-u-lg-offset-8{margin-left:66.66666667%}.am-u-lg-offset-9{margin-left:75%}.am-u-lg-offset-10{margin-left:83.33333333%}.am-u-lg-offset-11{margin-left:91.66666667%}.am-u-lg-reset-order{margin-left:0;margin-right:0;left:auto;right:auto;float:left}[class*=am-u-].am-u-lg-centered{margin-left:auto;margin-right:auto;float:none}[class*=am-u-].am-u-lg-centered:last-child{float:none}[class*=am-u-].am-u-lg-uncentered{margin-left:0;margin-right:0;float:left}[class*=am-u-].am-u-lg-uncentered:last-child{float:left}}[class*=am-avg-]{display:block;padding:0;margin:0;list-style:none}[class*=am-avg-]:after,[class*=am-avg-]:before{content:" ";display:table}[class*=am-avg-]:after{clear:both}[class*=am-avg-]>li{display:block;height:auto;float:left}@media only screen{.am-avg-sm-1>li{width:100%}.am-avg-sm-1>li:nth-of-type(n){clear:none}.am-avg-sm-1>li:nth-of-type(1n+1){clear:both}.am-avg-sm-2>li{width:50%}.am-avg-sm-2>li:nth-of-type(n){clear:none}.am-avg-sm-2>li:nth-of-type(2n+1){clear:both}.am-avg-sm-3>li{width:33.33333333%}.am-avg-sm-3>li:nth-of-type(n){clear:none}.am-avg-sm-3>li:nth-of-type(3n+1){clear:both}.am-avg-sm-4>li{width:25%}.am-avg-sm-4>li:nth-of-type(n){clear:none}.am-avg-sm-4>li:nth-of-type(4n+1){clear:both}.am-avg-sm-5>li{width:20%}.am-avg-sm-5>li:nth-of-type(n){clear:none}.am-avg-sm-5>li:nth-of-type(5n+1){clear:both}.am-avg-sm-6>li{width:16.66666667%}.am-avg-sm-6>li:nth-of-type(n){clear:none}.am-avg-sm-6>li:nth-of-type(6n+1){clear:both}.am-avg-sm-7>li{width:14.28571429%}.am-avg-sm-7>li:nth-of-type(n){clear:none}.am-avg-sm-7>li:nth-of-type(7n+1){clear:both}.am-avg-sm-8>li{width:12.5%}.am-avg-sm-8>li:nth-of-type(n){clear:none}.am-avg-sm-8>li:nth-of-type(8n+1){clear:both}.am-avg-sm-9>li{width:11.11111111%}.am-avg-sm-9>li:nth-of-type(n){clear:none}.am-avg-sm-9>li:nth-of-type(9n+1){clear:both}.am-avg-sm-10>li{width:10%}.am-avg-sm-10>li:nth-of-type(n){clear:none}.am-avg-sm-10>li:nth-of-type(10n+1){clear:both}.am-avg-sm-11>li{width:9.09090909%}.am-avg-sm-11>li:nth-of-type(n){clear:none}.am-avg-sm-11>li:nth-of-type(11n+1){clear:both}.am-avg-sm-12>li{width:8.33333333%}.am-avg-sm-12>li:nth-of-type(n){clear:none}.am-avg-sm-12>li:nth-of-type(12n+1){clear:both}}@media only screen and (min-width:641px){.am-avg-md-1>li{width:100%}.am-avg-md-1>li:nth-of-type(n){clear:none}.am-avg-md-1>li:nth-of-type(1n+1){clear:both}.am-avg-md-2>li{width:50%}.am-avg-md-2>li:nth-of-type(n){clear:none}.am-avg-md-2>li:nth-of-type(2n+1){clear:both}.am-avg-md-3>li{width:33.33333333%}.am-avg-md-3>li:nth-of-type(n){clear:none}.am-avg-md-3>li:nth-of-type(3n+1){clear:both}.am-avg-md-4>li{width:25%}.am-avg-md-4>li:nth-of-type(n){clear:none}.am-avg-md-4>li:nth-of-type(4n+1){clear:both}.am-avg-md-5>li{width:20%}.am-avg-md-5>li:nth-of-type(n){clear:none}.am-avg-md-5>li:nth-of-type(5n+1){clear:both}.am-avg-md-6>li{width:16.66666667%}.am-avg-md-6>li:nth-of-type(n){clear:none}.am-avg-md-6>li:nth-of-type(6n+1){clear:both}.am-avg-md-7>li{width:14.28571429%}.am-avg-md-7>li:nth-of-type(n){clear:none}.am-avg-md-7>li:nth-of-type(7n+1){clear:both}.am-avg-md-8>li{width:12.5%}.am-avg-md-8>li:nth-of-type(n){clear:none}.am-avg-md-8>li:nth-of-type(8n+1){clear:both}.am-avg-md-9>li{width:11.11111111%}.am-avg-md-9>li:nth-of-type(n){clear:none}.am-avg-md-9>li:nth-of-type(9n+1){clear:both}.am-avg-md-10>li{width:10%}.am-avg-md-10>li:nth-of-type(n){clear:none}.am-avg-md-10>li:nth-of-type(10n+1){clear:both}.am-avg-md-11>li{width:9.09090909%}.am-avg-md-11>li:nth-of-type(n){clear:none}.am-avg-md-11>li:nth-of-type(11n+1){clear:both}.am-avg-md-12>li{width:8.33333333%}.am-avg-md-12>li:nth-of-type(n){clear:none}.am-avg-md-12>li:nth-of-type(12n+1){clear:both}}@media only screen and (min-width:1025px){.am-avg-lg-1>li{width:100%}.am-avg-lg-1>li:nth-of-type(n){clear:none}.am-avg-lg-1>li:nth-of-type(1n+1){clear:both}.am-avg-lg-2>li{width:50%}.am-avg-lg-2>li:nth-of-type(n){clear:none}.am-avg-lg-2>li:nth-of-type(2n+1){clear:both}.am-avg-lg-3>li{width:33.33333333%}.am-avg-lg-3>li:nth-of-type(n){clear:none}.am-avg-lg-3>li:nth-of-type(3n+1){clear:both}.am-avg-lg-4>li{width:25%}.am-avg-lg-4>li:nth-of-type(n){clear:none}.am-avg-lg-4>li:nth-of-type(4n+1){clear:both}.am-avg-lg-5>li{width:20%}.am-avg-lg-5>li:nth-of-type(n){clear:none}.am-avg-lg-5>li:nth-of-type(5n+1){clear:both}.am-avg-lg-6>li{width:16.66666667%}.am-avg-lg-6>li:nth-of-type(n){clear:none}.am-avg-lg-6>li:nth-of-type(6n+1){clear:both}.am-avg-lg-7>li{width:14.28571429%}.am-avg-lg-7>li:nth-of-type(n){clear:none}.am-avg-lg-7>li:nth-of-type(7n+1){clear:both}.am-avg-lg-8>li{width:12.5%}.am-avg-lg-8>li:nth-of-type(n){clear:none}.am-avg-lg-8>li:nth-of-type(8n+1){clear:both}.am-avg-lg-9>li{width:11.11111111%}.am-avg-lg-9>li:nth-of-type(n){clear:none}.am-avg-lg-9>li:nth-of-type(9n+1){clear:both}.am-avg-lg-10>li{width:10%}.am-avg-lg-10>li:nth-of-type(n){clear:none}.am-avg-lg-10>li:nth-of-type(10n+1){clear:both}.am-avg-lg-11>li{width:9.09090909%}.am-avg-lg-11>li:nth-of-type(n){clear:none}.am-avg-lg-11>li:nth-of-type(11n+1){clear:both}.am-avg-lg-12>li{width:8.33333333%}.am-avg-lg-12>li:nth-of-type(n){clear:none}.am-avg-lg-12>li:nth-of-type(12n+1){clear:both}}code,kbd,pre,samp{font-family:Monaco,Menlo,Consolas,"Courier New",FontAwesome,monospace}code{padding:2px 4px;font-size:1.3rem;color:#c7254e;background-color:#f8f8f8;white-space:nowrap;border-radius:0}pre{display:block;padding:1rem;margin:1rem 0;font-size:1.3rem;line-height:1.6;word-break:break-all;word-wrap:break-word;color:#555;background-color:#f8f8f8;border:1px solid #dedede;border-radius:0}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.am-pre-scrollable{max-height:24rem;overflow-y:scroll}.am-btn{display:inline-block;margin-bottom:0;padding:.5em 1em;vertical-align:middle;font-size:1.6rem;font-weight:400;line-height:1.2;text-align:center;white-space:nowrap;background-image:none;border:1px solid transparent;border-radius:0;cursor:pointer;outline:0;-webkit-appearance:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transition:background-color .3s ease-out,border-color .3s ease-out;transition:background-color .3s ease-out,border-color .3s ease-out}.am-btn:active:focus,.am-btn:focus{outline:thin dotted;outline:1px auto -webkit-focus-ring-color;outline-offset:-2px}.am-btn:focus,.am-btn:hover{color:#444;text-decoration:none}.am-btn.am-active,.am-btn:active{background-image:none;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.15);box-shadow:inset 0 3px 5px rgba(0,0,0,.15)}.am-btn.am-disabled,.am-btn[disabled],fieldset[disabled] .am-btn{pointer-events:none;border-color:transparent;cursor:not-allowed;opacity:.45;-webkit-box-shadow:none;box-shadow:none}.am-btn.am-round{border-radius:1000px}.am-btn.am-radius{border-radius:2px}.am-btn-default{color:#444;background-color:#e6e6e6;border-color:#e6e6e6}a.am-btn-default:visited{color:#444}.am-btn-default.am-active,.am-btn-default:active,.am-btn-default:focus,.am-btn-default:hover,.am-dropdown.am-active .am-btn-default.am-dropdown-toggle{color:#444;border-color:#c7c7c7}.am-btn-default:focus,.am-btn-default:hover{background-color:#d4d4d4}.am-btn-default.am-active,.am-btn-default:active,.am-dropdown.am-active .am-btn-default.am-dropdown-toggle{background-image:none;background-color:#c2c2c2}.am-btn-default.am-disabled,.am-btn-default.am-disabled.am-active,.am-btn-default.am-disabled:active,.am-btn-default.am-disabled:focus,.am-btn-default.am-disabled:hover,.am-btn-default[disabled],.am-btn-default[disabled].am-active,.am-btn-default[disabled]:active,.am-btn-default[disabled]:focus,.am-btn-default[disabled]:hover,fieldset[disabled] .am-btn-default,fieldset[disabled] .am-btn-default.am-active,fieldset[disabled] .am-btn-default:active,fieldset[disabled] .am-btn-default:focus,fieldset[disabled] .am-btn-default:hover{background-color:#e6e6e6;border-color:#e6e6e6}.am-btn-group .am-btn-default,.am-btn-group-stacked .am-btn-default{border-color:#d9d9d9}.am-btn-primary{color:#fff;background-color:#0e90d2;border-color:#0e90d2}a.am-btn-primary:visited{color:#fff}.am-btn-primary.am-active,.am-btn-primary:active,.am-btn-primary:focus,.am-btn-primary:hover,.am-dropdown.am-active .am-btn-primary.am-dropdown-toggle{color:#fff;border-color:#0a6999}.am-btn-primary:focus,.am-btn-primary:hover{background-color:#0c79b1}.am-btn-primary.am-active,.am-btn-primary:active,.am-dropdown.am-active .am-btn-primary.am-dropdown-toggle{background-image:none;background-color:#0a628f}.am-btn-primary.am-disabled,.am-btn-primary.am-disabled.am-active,.am-btn-primary.am-disabled:active,.am-btn-primary.am-disabled:focus,.am-btn-primary.am-disabled:hover,.am-btn-primary[disabled],.am-btn-primary[disabled].am-active,.am-btn-primary[disabled]:active,.am-btn-primary[disabled]:focus,.am-btn-primary[disabled]:hover,fieldset[disabled] .am-btn-primary,fieldset[disabled] .am-btn-primary.am-active,fieldset[disabled] .am-btn-primary:active,fieldset[disabled] .am-btn-primary:focus,fieldset[disabled] .am-btn-primary:hover{background-color:#0e90d2;border-color:#0e90d2}.am-btn-group .am-btn-primary,.am-btn-group-stacked .am-btn-primary{border-color:#0c80ba}.am-btn-secondary{color:#fff;background-color:#3bb4f2;border-color:#3bb4f2}a.am-btn-secondary:visited{color:#fff}.am-btn-secondary.am-active,.am-btn-secondary:active,.am-btn-secondary:focus,.am-btn-secondary:hover,.am-dropdown.am-active .am-btn-secondary.am-dropdown-toggle{color:#fff;border-color:#0f9ae0}.am-btn-secondary:focus,.am-btn-secondary:hover{background-color:#19a7f0}.am-btn-secondary.am-active,.am-btn-secondary:active,.am-dropdown.am-active .am-btn-secondary.am-dropdown-toggle{background-image:none;background-color:#0e93d7}.am-btn-secondary.am-disabled,.am-btn-secondary.am-disabled.am-active,.am-btn-secondary.am-disabled:active,.am-btn-secondary.am-disabled:focus,.am-btn-secondary.am-disabled:hover,.am-btn-secondary[disabled],.am-btn-secondary[disabled].am-active,.am-btn-secondary[disabled]:active,.am-btn-secondary[disabled]:focus,.am-btn-secondary[disabled]:hover,fieldset[disabled] .am-btn-secondary,fieldset[disabled] .am-btn-secondary.am-active,fieldset[disabled] .am-btn-secondary:active,fieldset[disabled] .am-btn-secondary:focus,fieldset[disabled] .am-btn-secondary:hover{background-color:#3bb4f2;border-color:#3bb4f2}.am-btn-group .am-btn-secondary,.am-btn-group-stacked .am-btn-secondary{border-color:#23abf0}.am-btn-warning{color:#fff;background-color:#F37B1D;border-color:#F37B1D}a.am-btn-warning:visited{color:#fff}.am-btn-warning.am-active,.am-btn-warning:active,.am-btn-warning:focus,.am-btn-warning:hover,.am-dropdown.am-active .am-btn-warning.am-dropdown-toggle{color:#fff;border-color:#c85e0b}.am-btn-warning:focus,.am-btn-warning:hover{background-color:#e0690c}.am-btn-warning.am-active,.am-btn-warning:active,.am-dropdown.am-active .am-btn-warning.am-dropdown-toggle{background-image:none;background-color:#be590a}.am-btn-warning.am-disabled,.am-btn-warning.am-disabled.am-active,.am-btn-warning.am-disabled:active,.am-btn-warning.am-disabled:focus,.am-btn-warning.am-disabled:hover,.am-btn-warning[disabled],.am-btn-warning[disabled].am-active,.am-btn-warning[disabled]:active,.am-btn-warning[disabled]:focus,.am-btn-warning[disabled]:hover,fieldset[disabled] .am-btn-warning,fieldset[disabled] .am-btn-warning.am-active,fieldset[disabled] .am-btn-warning:active,fieldset[disabled] .am-btn-warning:focus,fieldset[disabled] .am-btn-warning:hover{background-color:#F37B1D;border-color:#F37B1D}.am-btn-group .am-btn-warning,.am-btn-group-stacked .am-btn-warning{border-color:#ea6e0c}.am-btn-danger{color:#fff;background-color:#dd514c;border-color:#dd514c}a.am-btn-danger:visited{color:#fff}.am-btn-danger.am-active,.am-btn-danger:active,.am-btn-danger:focus,.am-btn-danger:hover,.am-dropdown.am-active .am-btn-danger.am-dropdown-toggle{color:#fff;border-color:#c62b26}.am-btn-danger:focus,.am-btn-danger:hover{background-color:#d7342e}.am-btn-danger.am-active,.am-btn-danger:active,.am-dropdown.am-active .am-btn-danger.am-dropdown-toggle{background-image:none;background-color:#be2924}.am-btn-danger.am-disabled,.am-btn-danger.am-disabled.am-active,.am-btn-danger.am-disabled:active,.am-btn-danger.am-disabled:focus,.am-btn-danger.am-disabled:hover,.am-btn-danger[disabled],.am-btn-danger[disabled].am-active,.am-btn-danger[disabled]:active,.am-btn-danger[disabled]:focus,.am-btn-danger[disabled]:hover,fieldset[disabled] .am-btn-danger,fieldset[disabled] .am-btn-danger.am-active,fieldset[disabled] .am-btn-danger:active,fieldset[disabled] .am-btn-danger:focus,fieldset[disabled] .am-btn-danger:hover{background-color:#dd514c;border-color:#dd514c}.am-btn-group .am-btn-danger,.am-btn-group-stacked .am-btn-danger{border-color:#d93c37}.am-btn-success{color:#fff;background-color:#5eb95e;border-color:#5eb95e}a.am-btn-success:visited{color:#fff}.am-btn-success.am-active,.am-btn-success:active,.am-btn-success:focus,.am-btn-success:hover,.am-dropdown.am-active .am-btn-success.am-dropdown-toggle{color:#fff;border-color:#429842}.am-btn-success:focus,.am-btn-success:hover{background-color:#4aaa4a}.am-btn-success.am-active,.am-btn-success:active,.am-dropdown.am-active .am-btn-success.am-dropdown-toggle{background-image:none;background-color:#3f913f}.am-btn-success.am-disabled,.am-btn-success.am-disabled.am-active,.am-btn-success.am-disabled:active,.am-btn-success.am-disabled:focus,.am-btn-success.am-disabled:hover,.am-btn-success[disabled],.am-btn-success[disabled].am-active,.am-btn-success[disabled]:active,.am-btn-success[disabled]:focus,.am-btn-success[disabled]:hover,fieldset[disabled] .am-btn-success,fieldset[disabled] .am-btn-success.am-active,fieldset[disabled] .am-btn-success:active,fieldset[disabled] .am-btn-success:focus,fieldset[disabled] .am-btn-success:hover{background-color:#5eb95e;border-color:#5eb95e}.am-btn-group .am-btn-success,.am-btn-group-stacked .am-btn-success{border-color:#4db14d}.am-btn-link{color:#0e90d2;font-weight:400;cursor:pointer;border-radius:0}.am-btn-link,.am-btn-link:active,.am-btn-link[disabled],fieldset[disabled] .am-btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.am-btn-link,.am-btn-link:active,.am-btn-link:focus,.am-btn-link:hover{border-color:transparent}.am-btn-link:focus,.am-btn-link:hover{color:#095f8a;text-decoration:underline;background-color:transparent}.am-btn-link[disabled]:focus,.am-btn-link[disabled]:hover,fieldset[disabled] .am-btn-link:focus,fieldset[disabled] .am-btn-link:hover{color:#999;text-decoration:none}.am-btn-xs{font-size:1.2rem}.am-btn-sm{font-size:1.4rem}.am-btn-lg{font-size:1.8rem}.am-btn-xl{font-size:2rem}.am-btn-block{display:block;width:100%;padding-left:0;padding-right:0}.am-btn-block+.am-btn-block{margin-top:5px}input[type=button].am-btn-block,input[type=reset].am-btn-block,input[type=submit].am-btn-block{width:100%}.am-btn.am-btn-loading .am-icon-spin{margin-right:5px}table{max-width:100%;background-color:transparent;empty-cells:show}table code{white-space:normal}th{text-align:left}.am-table{width:100%;margin-bottom:1.6rem;border-spacing:0;border-collapse:separate}.am-table>tbody>tr>td,.am-table>tbody>tr>th,.am-table>tfoot>tr>td,.am-table>tfoot>tr>th,.am-table>thead>tr>td,.am-table>thead>tr>th{padding:.7rem;line-height:1.6;vertical-align:top;border-top:1px solid #ddd}.am-table>thead>tr>th{vertical-align:bottom;border-bottom:1px solid #ddd}.am-table>caption+thead>tr:first-child>td,.am-table>caption+thead>tr:first-child>th,.am-table>colgroup+thead>tr:first-child>td,.am-table>colgroup+thead>tr:first-child>th,.am-table>thead:first-child>tr:first-child>td,.am-table>thead:first-child>tr:first-child>th{border-top:0}.am-table>tbody+tbody tr:first-child td{border-top:2px solid #ddd}.am-table-bordered{border:1px solid #ddd;border-left:none}.am-table-bordered>tbody>tr>td,.am-table-bordered>tbody>tr>th,.am-table-bordered>tfoot>tr>td,.am-table-bordered>tfoot>tr>th,.am-table-bordered>thead>tr>td,.am-table-bordered>thead>tr>th{border-left:1px solid #ddd}.am-table-bordered>tbody>tr:first-child>td,.am-table-bordered>tbody>tr:first-child>th{border-top:none}.am-table-bordered>thead+tbody>tr:first-child>td,.am-table-bordered>thead+tbody>tr:first-child>th{border-top:1px solid #ddd}.am-table-radius{border:1px solid #ddd;border-radius:2px}.am-table-radius>thead>tr:first-child>td:first-child,.am-table-radius>thead>tr:first-child>th:first-child{border-top-left-radius:2px;border-left:none}.am-table-radius>thead>tr:first-child>td:last-child,.am-table-radius>thead>tr:first-child>th:last-child{border-top-right-radius:2px;border-right:none}.am-table-radius>tbody>tr>td:first-child,.am-table-radius>tbody>tr>th:first-child{border-left:none}.am-table-radius>tbody>tr>td:last-child,.am-table-radius>tbody>tr>th:last-child{border-right:none}.am-table-radius>tbody>tr:last-child>td,.am-table-radius>tbody>tr:last-child>th{border-bottom:none}.am-table-radius>tbody>tr:last-child>td:first-child,.am-table-radius>tbody>tr:last-child>th:first-child{border-bottom-left-radius:2px}.am-table-radius>tbody>tr:last-child>td:last-child,.am-table-radius>tbody>tr:last-child>th:last-child{border-bottom-right-radius:2px}.am-table-striped>tbody>tr:nth-child(odd)>td,.am-table-striped>tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.am-table-hover>tbody>tr:hover>td,.am-table-hover>tbody>tr:hover>th{background-color:#e9e9e9}.am-table-compact>tbody>tr>td,.am-table-compact>tbody>tr>th,.am-table-compact>tfoot>tr>td,.am-table-compact>tfoot>tr>th,.am-table-compact>thead>tr>td,.am-table-compact>thead>tr>th{padding:.4rem}.am-table-centered>tbody>tr>td,.am-table-centered>tbody>tr>th,.am-table-centered>tfoot>tr>td,.am-table-centered>tfoot>tr>th,.am-table-centered>thead>tr>td,.am-table-centered>thead>tr>th{text-align:center}.am-table>tbody>tr.am-active>td,.am-table>tbody>tr.am-active>th,.am-table>tbody>tr>td.am-active,.am-table>tbody>tr>th.am-active,.am-table>tfoot>tr.am-active>td,.am-table>tfoot>tr.am-active>th,.am-table>tfoot>tr>td.am-active,.am-table>tfoot>tr>th.am-active,.am-table>thead>tr.am-active>td,.am-table>thead>tr.am-active>th,.am-table>thead>tr>td.am-active,.am-table>thead>tr>th.am-active{background-color:#ffd}.am-table>tbody>tr.am-disabled>td,.am-table>tbody>tr.am-disabled>th,.am-table>tbody>tr>td.am-disabled,.am-table>tbody>tr>th.am-disabled,.am-table>tfoot>tr.am-disabled>td,.am-table>tfoot>tr.am-disabled>th,.am-table>tfoot>tr>td.am-disabled,.am-table>tfoot>tr>th.am-disabled,.am-table>thead>tr.am-disabled>td,.am-table>thead>tr.am-disabled>th,.am-table>thead>tr>td.am-disabled,.am-table>thead>tr>th.am-disabled{color:#999}.am-table>tbody>tr.am-primary>td,.am-table>tbody>tr.am-primary>th,.am-table>tbody>tr>td.am-primary,.am-table>tbody>tr>th.am-primary,.am-table>tfoot>tr.am-primary>td,.am-table>tfoot>tr.am-primary>th,.am-table>tfoot>tr>td.am-primary,.am-table>tfoot>tr>th.am-primary,.am-table>thead>tr.am-primary>td,.am-table>thead>tr.am-primary>th,.am-table>thead>tr>td.am-primary,.am-table>thead>tr>th.am-primary{color:#0b76ac;background-color:rgba(14,144,210,.115)}.am-table>tbody>tr.am-success>td,.am-table>tbody>tr.am-success>th,.am-table>tbody>tr>td.am-success,.am-table>tbody>tr>th.am-success,.am-table>tfoot>tr.am-success>td,.am-table>tfoot>tr.am-success>th,.am-table>tfoot>tr>td.am-success,.am-table>tfoot>tr>th.am-success,.am-table>thead>tr.am-success>td,.am-table>thead>tr.am-success>th,.am-table>thead>tr>td.am-success,.am-table>thead>tr>th.am-success{color:#5eb95e;background-color:rgba(94,185,94,.115)}.am-table>tbody>tr.am-warning>td,.am-table>tbody>tr.am-warning>th,.am-table>tbody>tr>td.am-warning,.am-table>tbody>tr>th.am-warning,.am-table>tfoot>tr.am-warning>td,.am-table>tfoot>tr.am-warning>th,.am-table>tfoot>tr>td.am-warning,.am-table>tfoot>tr>th.am-warning,.am-table>thead>tr.am-warning>td,.am-table>thead>tr.am-warning>th,.am-table>thead>tr>td.am-warning,.am-table>thead>tr>th.am-warning{color:#F37B1D;background-color:rgba(243,123,29,.115)}.am-table>tbody>tr.am-danger>td,.am-table>tbody>tr.am-danger>th,.am-table>tbody>tr>td.am-danger,.am-table>tbody>tr>th.am-danger,.am-table>tfoot>tr.am-danger>td,.am-table>tfoot>tr.am-danger>th,.am-table>tfoot>tr>td.am-danger,.am-table>tfoot>tr>th.am-danger,.am-table>thead>tr.am-danger>td,.am-table>thead>tr.am-danger>th,.am-table>thead>tr>td.am-danger,.am-table>thead>tr>th.am-danger{color:#dd514c;background-color:rgba(221,81,76,.115)}fieldset{border:none}legend{display:block;width:100%;margin-bottom:2rem;font-size:2rem;line-height:inherit;color:#333;border-bottom:1px solid #e5e5e5;padding-bottom:.5rem}label{display:inline-block;margin-bottom:5px;font-weight:700}input[type=search]{-webkit-box-sizing:border-box;box-sizing:border-box}input[type=checkbox],input[type=radio]{margin:4px 0 0;margin-top:1px\9;line-height:normal}input[type=file]{display:block}select[multiple],select[size]{height:auto}select optgroup{font-size:inherit;font-style:inherit;font-family:inherit}input[type=checkbox]:focus,input[type=file]:focus,input[type=radio]:focus{outline:thin dotted;outline:1px auto -webkit-focus-ring-color;outline-offset:-2px}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}output{display:block;padding-top:1.6rem;font-size:1.6rem;line-height:1.6;color:#555;vertical-align:middle}.am-form input[type=number],.am-form input[type=search],.am-form input[type=text],.am-form input[type=password],.am-form input[type=datetime],.am-form input[type=datetime-local],.am-form input[type=date],.am-form input[type=month],.am-form input[type=time],.am-form input[type=week],.am-form input[type=email],.am-form input[type=url],.am-form input[type=tel],.am-form input[type=color],.am-form select,.am-form textarea,.am-form-field{display:block;width:100%;padding:.5em;font-size:1.6rem;line-height:1.2;color:#555;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:0;-webkit-appearance:none;-webkit-transition:border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;transition:border-color .15s ease-in-out,-webkit-box-shadow .15s ease-in-out;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out,-webkit-box-shadow .15s ease-in-out}.am-form input[type=number]:focus,.am-form input[type=search]:focus,.am-form input[type=text]:focus,.am-form input[type=password]:focus,.am-form input[type=datetime]:focus,.am-form input[type=datetime-local]:focus,.am-form input[type=date]:focus,.am-form input[type=month]:focus,.am-form input[type=time]:focus,.am-form input[type=week]:focus,.am-form input[type=email]:focus,.am-form input[type=url]:focus,.am-form input[type=tel]:focus,.am-form input[type=color]:focus,.am-form select:focus,.am-form textarea:focus,.am-form-field:focus{outline:0}.am-form input[type=number]:focus,.am-form input[type=search]:focus,.am-form input[type=text]:focus,.am-form input[type=password]:focus,.am-form input[type=datetime]:focus,.am-form input[type=datetime-local]:focus,.am-form input[type=date]:focus,.am-form input[type=month]:focus,.am-form input[type=time]:focus,.am-form input[type=week]:focus,.am-form input[type=email]:focus,.am-form input[type=url]:focus,.am-form input[type=tel]:focus,.am-form input[type=color]:focus,.am-form select:focus,.am-form textarea:focus,.am-form-field:focus{background-color:#fefffe;border-color:#3bb4f2;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px rgba(59,180,242,.3);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px rgba(59,180,242,.3)}.am-form input[type=number]::-webkit-input-placeholder,.am-form input[type=search]::-webkit-input-placeholder,.am-form input[type=text]::-webkit-input-placeholder,.am-form input[type=password]::-webkit-input-placeholder,.am-form input[type=datetime]::-webkit-input-placeholder,.am-form input[type=datetime-local]::-webkit-input-placeholder,.am-form input[type=date]::-webkit-input-placeholder,.am-form input[type=month]::-webkit-input-placeholder,.am-form input[type=time]::-webkit-input-placeholder,.am-form input[type=week]::-webkit-input-placeholder,.am-form input[type=email]::-webkit-input-placeholder,.am-form input[type=url]::-webkit-input-placeholder,.am-form input[type=tel]::-webkit-input-placeholder,.am-form input[type=color]::-webkit-input-placeholder,.am-form select::-webkit-input-placeholder,.am-form textarea::-webkit-input-placeholder,.am-form-field::-webkit-input-placeholder{color:#999}.am-form input[type=number]::-moz-placeholder,.am-form input[type=search]::-moz-placeholder,.am-form input[type=text]::-moz-placeholder,.am-form input[type=password]::-moz-placeholder,.am-form input[type=datetime]::-moz-placeholder,.am-form input[type=datetime-local]::-moz-placeholder,.am-form input[type=date]::-moz-placeholder,.am-form input[type=month]::-moz-placeholder,.am-form input[type=time]::-moz-placeholder,.am-form input[type=week]::-moz-placeholder,.am-form input[type=email]::-moz-placeholder,.am-form input[type=url]::-moz-placeholder,.am-form input[type=tel]::-moz-placeholder,.am-form input[type=color]::-moz-placeholder,.am-form select::-moz-placeholder,.am-form textarea::-moz-placeholder,.am-form-field::-moz-placeholder{color:#999}.am-form input[type=number]:-ms-input-placeholder,.am-form input[type=search]:-ms-input-placeholder,.am-form input[type=text]:-ms-input-placeholder,.am-form input[type=password]:-ms-input-placeholder,.am-form input[type=datetime]:-ms-input-placeholder,.am-form input[type=datetime-local]:-ms-input-placeholder,.am-form input[type=date]:-ms-input-placeholder,.am-form input[type=month]:-ms-input-placeholder,.am-form input[type=time]:-ms-input-placeholder,.am-form input[type=week]:-ms-input-placeholder,.am-form input[type=email]:-ms-input-placeholder,.am-form input[type=url]:-ms-input-placeholder,.am-form input[type=tel]:-ms-input-placeholder,.am-form input[type=color]:-ms-input-placeholder,.am-form select:-ms-input-placeholder,.am-form textarea:-ms-input-placeholder,.am-form-field:-ms-input-placeholder{color:#999}.am-form input[type=number]::placeholder,.am-form input[type=search]::placeholder,.am-form input[type=text]::placeholder,.am-form input[type=password]::placeholder,.am-form input[type=datetime]::placeholder,.am-form input[type=datetime-local]::placeholder,.am-form input[type=date]::placeholder,.am-form input[type=month]::placeholder,.am-form input[type=time]::placeholder,.am-form input[type=week]::placeholder,.am-form input[type=email]::placeholder,.am-form input[type=url]::placeholder,.am-form input[type=tel]::placeholder,.am-form input[type=color]::placeholder,.am-form select::placeholder,.am-form textarea::placeholder,.am-form-field::placeholder{color:#999}.am-form input[type=number]::-moz-placeholder,.am-form input[type=search]::-moz-placeholder,.am-form input[type=text]::-moz-placeholder,.am-form input[type=password]::-moz-placeholder,.am-form input[type=datetime]::-moz-placeholder,.am-form input[type=datetime-local]::-moz-placeholder,.am-form input[type=date]::-moz-placeholder,.am-form input[type=month]::-moz-placeholder,.am-form input[type=time]::-moz-placeholder,.am-form input[type=week]::-moz-placeholder,.am-form input[type=email]::-moz-placeholder,.am-form input[type=url]::-moz-placeholder,.am-form input[type=tel]::-moz-placeholder,.am-form input[type=color]::-moz-placeholder,.am-form select::-moz-placeholder,.am-form textarea::-moz-placeholder,.am-form-field::-moz-placeholder{opacity:1}.am-form input[type=number][disabled],.am-form input[type=number][readonly],.am-form input[type=search][disabled],.am-form input[type=search][readonly],.am-form input[type=text][disabled],.am-form input[type=text][readonly],.am-form input[type=password][disabled],.am-form input[type=password][readonly],.am-form input[type=datetime][disabled],.am-form input[type=datetime][readonly],.am-form input[type=datetime-local][disabled],.am-form input[type=datetime-local][readonly],.am-form input[type=date][disabled],.am-form input[type=date][readonly],.am-form input[type=month][disabled],.am-form input[type=month][readonly],.am-form input[type=time][disabled],.am-form input[type=time][readonly],.am-form input[type=week][disabled],.am-form input[type=week][readonly],.am-form input[type=email][disabled],.am-form input[type=email][readonly],.am-form input[type=url][disabled],.am-form input[type=url][readonly],.am-form input[type=tel][disabled],.am-form input[type=tel][readonly],.am-form input[type=color][disabled],.am-form input[type=color][readonly],.am-form select[disabled],.am-form select[readonly],.am-form textarea[disabled],.am-form textarea[readonly],.am-form-field[disabled],.am-form-field[readonly],fieldset[disabled] .am-form input[type=number],fieldset[disabled] .am-form input[type=search],fieldset[disabled] .am-form input[type=text],fieldset[disabled] .am-form input[type=password],fieldset[disabled] .am-form input[type=datetime],fieldset[disabled] .am-form input[type=datetime-local],fieldset[disabled] .am-form input[type=date],fieldset[disabled] .am-form input[type=month],fieldset[disabled] .am-form input[type=time],fieldset[disabled] .am-form input[type=week],fieldset[disabled] .am-form input[type=email],fieldset[disabled] .am-form input[type=url],fieldset[disabled] .am-form input[type=tel],fieldset[disabled] .am-form input[type=color],fieldset[disabled] .am-form select,fieldset[disabled] .am-form textarea,fieldset[disabled] .am-form-field{cursor:not-allowed;background-color:#eee}.am-form input[type=number].am-radius,.am-form input[type=search].am-radius,.am-form input[type=text].am-radius,.am-form input[type=password].am-radius,.am-form input[type=datetime].am-radius,.am-form input[type=datetime-local].am-radius,.am-form input[type=date].am-radius,.am-form input[type=month].am-radius,.am-form input[type=time].am-radius,.am-form input[type=week].am-radius,.am-form input[type=email].am-radius,.am-form input[type=url].am-radius,.am-form input[type=tel].am-radius,.am-form input[type=color].am-radius,.am-form select.am-radius,.am-form textarea.am-radius,.am-form-field.am-radius{border-radius:2px}.am-form input[type=number].am-round,.am-form input[type=search].am-round,.am-form input[type=text].am-round,.am-form input[type=password].am-round,.am-form input[type=datetime].am-round,.am-form input[type=datetime-local].am-round,.am-form input[type=date].am-round,.am-form input[type=month].am-round,.am-form input[type=time].am-round,.am-form input[type=week].am-round,.am-form input[type=email].am-round,.am-form input[type=url].am-round,.am-form input[type=tel].am-round,.am-form input[type=color].am-round,.am-form select.am-round,.am-form textarea.am-round,.am-form-field.am-round{border-radius:1000px}.am-form select[multiple],.am-form select[size],.am-form textarea{height:auto}.am-form select{-webkit-appearance:none!important;-moz-appearance:none!important;-webkit-border-radius:0;background:#fff url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMTJweCIgeT0iMHB4IiB3aWR0aD0iMjRweCIgaGVpZ2h0PSIzcHgiIHZpZXdCb3g9IjAgMCA2IDMiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDYgMyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBvbHlnb24gcG9pbnRzPSI1Ljk5MiwwIDIuOTkyLDMgLTAuMDA4LDAgIi8+PC9zdmc+) no-repeat 100% center}.am-form select[multiple=multiple]{background-image:none}.am-form input[type=datetime-local],.am-form input[type=date],input[type=datetime-local].am-form-field,input[type=date].am-form-field{height:37px}.am-form input[type=datetime-local].am-input-sm,.am-form input[type=date].am-input-sm,input[type=datetime-local].am-form-field.am-input-sm,input[type=date].am-form-field.am-input-sm{height:32px}.am-form input[type=datetime-local] .am-input-lg,.am-form input[type=date] .am-input-lg,input[type=datetime-local].am-form-field .am-input-lg,input[type=date].am-form-field .am-input-lg{height:41px}.am-form-help{display:block;margin-top:5px;margin-bottom:10px;color:#999;font-size:1.3rem}.am-form-group{margin-bottom:1.5rem}.am-form-file{position:relative;overflow:hidden}.am-form-file input[type=file]{position:absolute;left:0;top:0;z-index:1;width:100%;opacity:0;cursor:pointer;font-size:50rem}.am-checkbox,.am-radio{display:block;min-height:1.92rem;margin-top:10px;margin-bottom:10px;padding-left:20px;vertical-align:middle}.am-checkbox label,.am-radio label{display:inline;margin-bottom:0;font-weight:400;cursor:pointer}.am-checkbox input[type=checkbox],.am-checkbox-inline input[type=checkbox],.am-radio input[type=radio],.am-radio-inline input[type=radio]{float:left;margin-left:-20px;outline:0}.am-checkbox+.am-checkbox,.am-radio+.am-radio{margin-top:-5px}.am-checkbox-inline,.am-radio-inline{display:inline-block;padding-left:20px;margin-bottom:0;vertical-align:middle;font-weight:400;cursor:pointer}.am-checkbox-inline+.am-checkbox-inline,.am-radio-inline+.am-radio-inline{margin-top:0;margin-left:10px}.am-checkbox-inline[disabled],.am-checkbox[disabled],.am-radio-inline[disabled],.am-radio[disabled],fieldset[disabled] .am-checkbox,fieldset[disabled] .am-checkbox-inline,fieldset[disabled] .am-radio,fieldset[disabled] .am-radio-inline,fieldset[disabled] input[type=checkbox],fieldset[disabled] input[type=radio],input[type=checkbox][disabled],input[type=radio][disabled]{cursor:not-allowed}.am-form-warning .am-checkbox,.am-form-warning .am-checkbox-inline,.am-form-warning .am-form-help,.am-form-warning .am-form-label,.am-form-warning .am-radio,.am-form-warning .am-radio-inline,.am-form-warning label{color:#F37B1D}.am-form-warning [class*=icon-]{color:#F37B1D}.am-form-warning .am-form-field{border-color:#F37B1D!important;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.am-form-warning .am-form-field:focus{background-color:#fefffe;border-color:#d2620b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #f8b47e!important;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #f8b47e!important}.am-form-error .am-checkbox,.am-form-error .am-checkbox-inline,.am-form-error .am-form-help,.am-form-error .am-form-label,.am-form-error .am-radio,.am-form-error .am-radio-inline,.am-form-error label{color:#dd514c}.am-form-error [class*=icon-]{color:#dd514c}.am-field-error,.am-form-error .am-form-field{border-color:#dd514c!important;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.am-field-error:focus,.am-form-error .am-form-field:focus{background-color:#fefffe;border-color:#cf2d27;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #eda4a2!important;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #eda4a2!important}.am-form-success .am-checkbox,.am-form-success .am-checkbox-inline,.am-form-success .am-form-help,.am-form-success .am-form-label,.am-form-success .am-radio,.am-form-success .am-radio-inline,.am-form-success label{color:#5eb95e}.am-form-success [class*=icon-]{color:#5eb95e}.am-field-valid,.am-form-success .am-form-field{border-color:#5eb95e!important;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.am-field-valid:focus,.am-form-success .am-form-field:focus{background-color:#fefffe;border-color:#459f45;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #a5d8a5!important;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 5px #a5d8a5!important}.am-form-horizontal .am-checkbox,.am-form-horizontal .am-checkbox-inline,.am-form-horizontal .am-form-label,.am-form-horizontal .am-radio,.am-form-horizontal .am-radio-inline{margin-top:0;margin-bottom:0;padding-top:.6em}.am-form-horizontal .am-form-group:after,.am-form-horizontal .am-form-group:before{content:" ";display:table}.am-form-horizontal .am-form-group:after{clear:both}@media only screen and (min-width:641px){.am-form-horizontal .am-form-label{text-align:right}}@media only screen and (min-width:641px){.am-form-inline .am-form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.am-form-inline .am-form-field{display:inline-block;width:auto;vertical-align:middle}.am-form-inline .am-input-group{display:inline-table;vertical-align:middle}.am-form-inline .am-input-group .am-form-label,.am-form-inline .am-input-group .am-input-group-btn,.am-form-inline .am-input-group .am-input-group-label{width:auto}.am-form-inline .am-input-group>.am-form-field{width:100%}.am-form-inline .am-form-label{margin-bottom:0;vertical-align:middle}.am-form-inline .am-checkbox,.am-form-inline .am-radio{display:inline-block;margin-top:0;margin-bottom:0;padding-left:0;vertical-align:middle}.am-form-inline .am-checkbox input[type=checkbox],.am-form-inline .am-radio input[type=radio]{float:none;margin-left:0}}.am-input-sm{font-size:1.4rem!important}.am-input-lg{font-size:1.8rem!important}.am-form-group-sm .am-checkbox,.am-form-group-sm .am-form-field,.am-form-group-sm .am-form-label,.am-form-group-sm .am-radio{font-size:1.4rem!important}.am-form-group-lg .am-checkbox,.am-form-group-lg .am-form-field,.am-form-group-lg .am-form-label,.am-form-group-lg .am-radio{font-size:1.8rem!important}.am-form-group-lg input[type=checkbox],.am-form-group-lg input[type=radio]{margin-top:7px}.am-form-icon{position:relative}.am-form-icon .am-form-field{padding-left:1.75em!important}.am-form-icon [class*=am-icon-]{position:absolute;left:.5em;top:50%;display:block;margin-top:-.5em;line-height:1;z-index:2}.am-form-icon label~[class*=am-icon-]{top:70%}.am-form-feedback{position:relative}.am-form-feedback .am-form-field{padding-left:.5em!important;padding-right:1.75em!important}.am-form-feedback [class*=am-icon-]{right:.5em;left:auto}.am-form-horizontal .am-form-feedback [class*=am-icon-]{right:1.6em}.am-form-set{margin-bottom:1.5rem;padding:0}.am-form-set>input{position:relative;top:-1px;border-radius:0!important}.am-form-set>input:focus{z-index:2}.am-form-set>input:first-child{top:1px;border-top-right-radius:0!important;border-top-left-radius:0!important}.am-form-set>input:last-child{top:-2px;border-bottom-right-radius:0!important;border-bottom-left-radius:0!important}.am-img-thumbnail{display:inline-block;max-width:100%;height:auto;padding:2px;line-height:1.6;background-color:#fff;border:1px solid #ddd;border-radius:0;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.am-img-thumbnail.am-radius{border-radius:2px}.am-img-responsive{display:block;max-width:100%;height:auto}.am-nav{margin-bottom:0;padding:0;list-style:none}.am-nav:after,.am-nav:before{content:" ";display:table}.am-nav:after{clear:both}.am-nav>li{position:relative;display:block}.am-nav>li+li{margin-top:5px}.am-nav>li+.am-nav-header{margin-top:1em}.am-nav>li>a{position:relative;display:block;padding:.4em 1em;border-radius:0}.am-nav>li>a:focus,.am-nav>li>a:hover{text-decoration:none;background-color:#eee}.am-nav>li.am-active>a,.am-nav>li.am-active>a:focus,.am-nav>li.am-active>a:hover{color:#fff;background-color:#0e90d2;cursor:default}.am-nav>li.am-disabled>a{color:#999}.am-nav>li.am-disabled>a:focus,.am-nav>li.am-disabled>a:hover{color:#999;text-decoration:none;background-color:transparent;cursor:not-allowed}.am-nav-header{padding:.4em 1em;text-transform:uppercase;font-weight:700;font-size:100%;color:#555}.am-nav-divider{margin:15px 1em!important;border-top:1px solid #ddd;-webkit-box-shadow:0 1px 0 #fff;box-shadow:0 1px 0 #fff}.am-nav-pills>li{float:left}.am-nav-pills>li+li{margin-left:5px;margin-top:0}.am-nav-tabs{border-bottom:1px solid #ddd}.am-nav-tabs>li{float:left;margin-bottom:-1px}.am-nav-tabs>li+li{margin-top:0}.am-nav-tabs>li>a{margin-right:5px;line-height:1.6;border:1px solid transparent;border-radius:0}.am-nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.am-nav-tabs>li.am-active>a,.am-nav-tabs>li.am-active>a:focus,.am-nav-tabs>li.am-active>a:hover{color:#555;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent;cursor:default}.am-nav-tabs.am-nav-justify{border-bottom:0}.am-nav-tabs.am-nav-justify>li>a{margin-right:0;border-bottom:1px solid #ddd;border-radius:0}.am-nav-tabs.am-nav-justify>.am-active>a,.am-nav-tabs.am-nav-justify>.am-active>a:focus,.am-nav-tabs.am-nav-justify>.am-active>a:hover{border-bottom-color:#fff}.am-nav-justify{width:100%}.am-nav-justify>li{float:none;display:table-cell;width:1%}.am-nav-justify>li>a{text-align:center;margin-bottom:0}.lte9 .am-nav-justify>li{display:table-cell;width:1%}.am-topbar{position:relative;min-height:50px;margin-bottom:1.6rem;background:#f8f8f8;border-width:0 0 1px;border-style:solid;border-color:#ddd;color:#666}.am-topbar:after,.am-topbar:before{content:" ";display:table}.am-topbar:after{clear:both}.am-topbar a{color:#666}.am-topbar-brand{margin:0}@media only screen and (min-width:641px){.am-topbar-brand{float:left}}.am-topbar-brand a:hover{color:#4d4d4d}.am-topbar-collapse{width:100%;overflow-x:visible;padding:10px;clear:both;-webkit-overflow-scrolling:touch}.am-topbar-collapse:after,.am-topbar-collapse:before{content:" ";display:table}.am-topbar-collapse:after{clear:both}.am-topbar-collapse.am-in{overflow-y:auto}@media only screen and (min-width:641px){.am-topbar-collapse{margin-top:0;padding:0;width:auto;clear:none}.am-topbar-collapse.am-collapse{display:block!important;height:auto!important;padding:0;overflow:visible!important}.am-topbar-collapse.am-in{overflow-y:visible}}.am-topbar-brand{padding:0 10px;float:left;font-size:1.8rem;height:50px;line-height:50px}.am-topbar-toggle{position:relative;float:right;margin-right:10px}@media only screen and (min-width:641px){.am-topbar-toggle{display:none}}@media only screen and (max-width:640px){.am-topbar-nav{margin-bottom:8px}.am-topbar-nav>li{float:none}}@media only screen and (max-width:640px){.am-topbar-nav>li+li{margin-left:0;margin-top:5px}}@media only screen and (min-width:641px){.am-topbar-nav{float:left}.am-topbar-nav>li>a{position:relative;line-height:50px;padding:0 10px}.am-topbar-nav>li>a:after{position:absolute;left:50%;margin-left:-7px;bottom:-1px;content:"";display:inline-block;width:0;height:0;vertical-align:middle;border-bottom:7px solid #f8f8f8;border-right:7px solid transparent;border-left:7px solid transparent;border-top:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);opacity:0;-webkit-transition:opacity .1s;transition:opacity .1s}.am-topbar-nav>li>a:hover:after{opacity:1;border-bottom-color:#666}.am-topbar-nav>li.am-dropdown>a:after{display:none}.am-topbar-nav>li.am-active>a,.am-topbar-nav>li.am-active>a:focus,.am-topbar-nav>li.am-active>a:hover{border-radius:0;color:#0e90d2;background:0 0}.am-topbar-nav>li.am-active>a:after{opacity:1;border-bottom-color:#0e90d2}}@media only screen and (max-width:640px){.am-topbar-collapse .am-dropdown.am-active .am-dropdown-content{float:none;position:relative;width:100%}}@media only screen and (min-width:641px){.am-topbar-left{float:left}.am-topbar-right{float:right;margin-right:10px}}@media only screen and (max-width:640px){.am-topbar-form .am-form-group{margin-bottom:5px}}@media only screen and (min-width:641px){.am-topbar-form{padding:0 10px;margin-top:8px}.am-topbar-form .am-form-group+.am-btn{margin-left:5px}}.am-topbar-btn{margin-top:8px}@media only screen and (max-width:640px){.am-topbar-collapse .am-btn,.am-topbar-collapse .am-topbar-btn{display:block;width:100%}}.am-topbar-inverse{background-color:#0e90d2;border-color:#0b6fa2;color:#eee}.am-topbar-inverse a{color:#eee}.am-topbar-inverse .am-topbar-brand a{color:#fff}.am-topbar-inverse .am-topbar-brand a:focus,.am-topbar-inverse .am-topbar-brand a:hover{color:#fff;background-color:transparent}.am-topbar-inverse .am-topbar-nav>li>a{color:#eee}.am-topbar-inverse .am-topbar-nav>li>a:focus,.am-topbar-inverse .am-topbar-nav>li>a:hover{color:#fff;background-color:rgba(0,0,0,.05)}.am-topbar-inverse .am-topbar-nav>li>a:focus:after,.am-topbar-inverse .am-topbar-nav>li>a:hover:after{border-bottom-color:#0b6fa2}.am-topbar-inverse .am-topbar-nav>li>a:after{border-bottom-color:#0e90d2}.am-topbar-inverse .am-topbar-nav>li.am-active>a,.am-topbar-inverse .am-topbar-nav>li.am-active>a:focus,.am-topbar-inverse .am-topbar-nav>li.am-active>a:hover{color:#fff;background-color:rgba(0,0,0,.1)}.am-topbar-inverse .am-topbar-nav>li.am-active>a:after,.am-topbar-inverse .am-topbar-nav>li.am-active>a:focus:after,.am-topbar-inverse .am-topbar-nav>li.am-active>a:hover:after{border-bottom-color:#fff}.am-topbar-inverse .am-topbar-nav>li .disabled>a,.am-topbar-inverse .am-topbar-nav>li .disabled>a:focus,.am-topbar-inverse .am-topbar-nav>li .disabled>a:hover{color:#444;background-color:transparent}.am-topbar-fixed-bottom,.am-topbar-fixed-top{position:fixed;right:0;left:0;z-index:1000;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}.am-topbar-fixed-top{top:0}.am-topbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.am-with-topbar-fixed-top{padding-top:51px}.am-with-topbar-fixed-bottom{padding-bottom:51px}@media only screen and (max-width:640px){.am-topbar-fixed-bottom .am-topbar-collapse{position:absolute;bottom:100%;margin-bottom:1px;background-color:#f8f8f8}.am-topbar-fixed-bottom .am-topbar-collapse .am-dropdown-content:after,.am-topbar-fixed-bottom .am-topbar-collapse .am-dropdown-content:before{display:none}.am-topbar-fixed-bottom.am-topbar-inverse .am-topbar-collapse{background-color:#0e90d2}}.am-breadcrumb{padding:.7em .5em;margin-bottom:2rem;list-style:none;background-color:transparent;border-radius:0;font-size:85%}.am-breadcrumb>li{display:inline-block}.am-breadcrumb>li [class*=am-icon-]:before{color:#999;margin-right:5px}.am-breadcrumb>li+li:before{content:"\00bb\00a0";padding:0 8px;color:#ccc}.am-breadcrumb>.am-active{color:#999}.am-breadcrumb-slash>li+li:before{content:"/\00a0"}.am-pagination{padding-left:0;margin:1.5rem 0;list-style:none;color:#999;text-align:left}.am-pagination:after,.am-pagination:before{content:" ";display:table}.am-pagination:after{clear:both}.am-pagination>li{display:inline-block}.am-pagination>li>a,.am-pagination>li>span{position:relative;display:block;padding:.5em 1em;text-decoration:none;line-height:1.2;background-color:#fff;border:1px solid #ddd;border-radius:0;margin-bottom:5px;margin-right:5px}.am-pagination>li:last-child>a,.am-pagination>li:last-child>span{margin-right:0}.am-pagination>li>a:focus,.am-pagination>li>a:hover,.am-pagination>li>span:focus,.am-pagination>li>span:hover{background-color:#eee}.am-pagination>.am-active>a,.am-pagination>.am-active>a:focus,.am-pagination>.am-active>a:hover,.am-pagination>.am-active>span,.am-pagination>.am-active>span:focus,.am-pagination>.am-active>span:hover{z-index:2;color:#fff;background-color:#0e90d2;border-color:#0e90d2;cursor:default}.am-pagination>.am-disabled>a,.am-pagination>.am-disabled>a:focus,.am-pagination>.am-disabled>a:hover,.am-pagination>.am-disabled>span,.am-pagination>.am-disabled>span:focus,.am-pagination>.am-disabled>span:hover{color:#999;background-color:#fff;border-color:#ddd;cursor:not-allowed;pointer-events:none}.am-pagination .am-pagination-prev{float:left}.am-pagination .am-pagination-prev a{border-radius:0}.am-pagination .am-pagination-next{float:right}.am-pagination .am-pagination-next a{border-radius:0}.am-pagination-centered{text-align:center}.am-pagination-right{text-align:right}[class*=am-animation-]{-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out;-webkit-animation-fill-mode:both;animation-fill-mode:both}@media screen{.cssanimations [data-am-scrollspy*=animation]{opacity:0}}.am-animation-fade{-webkit-animation-name:am-fade;animation-name:am-fade;-webkit-animation-duration:.8s;animation-duration:.8s;-webkit-animation-timing-function:linear;animation-timing-function:linear}.am-animation-scale-up{-webkit-animation-name:am-scale-up;animation-name:am-scale-up}.am-animation-scale-down{-webkit-animation-name:am-scale-down;animation-name:am-scale-down}.am-animation-slide-top{-webkit-animation-name:am-slide-top;animation-name:am-slide-top}.am-animation-slide-bottom{-webkit-animation-name:am-slide-bottom;animation-name:am-slide-bottom}.am-animation-slide-left{-webkit-animation-name:am-slide-left;animation-name:am-slide-left}.am-animation-slide-right{-webkit-animation-name:am-slide-right;animation-name:am-slide-right}.am-animation-slide-top-fixed{-webkit-animation-name:am-slide-top-fixed;animation-name:am-slide-top-fixed}.am-animation-shake{-webkit-animation-name:am-shake;animation-name:am-shake}.am-animation-spin{-webkit-animation:am-spin 2s infinite linear;animation:am-spin 2s infinite linear}.am-animation-left-spring{-webkit-animation:am-left-spring .3s ease-in-out;animation:am-left-spring .3s ease-in-out}.am-animation-right-spring{-webkit-animation:am-right-spring .3s ease-in-out;animation:am-right-spring .3s ease-in-out}.am-animation-reverse{-webkit-animation-direction:reverse;animation-direction:reverse}.am-animation-paused{-webkit-animation-play-state:paused!important;animation-play-state:paused!important}.am-animation-delay-1{-webkit-animation-delay:1s;animation-delay:1s}.am-animation-delay-2{-webkit-animation-delay:2s;animation-delay:2s}.am-animation-delay-3{-webkit-animation-delay:3s;animation-delay:3s}.am-animation-delay-4{-webkit-animation-delay:4s;animation-delay:4s}.am-animation-delay-5{-webkit-animation-delay:5s;animation-delay:5s}.am-animation-delay-6{-webkit-animation-delay:6s;animation-delay:6s}@-webkit-keyframes am-fade{0%{opacity:0}100%{opacity:1}}@keyframes am-fade{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes am-scale-up{0%{opacity:0;-webkit-transform:scale(.2);transform:scale(.2)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes am-scale-up{0%{opacity:0;-webkit-transform:scale(.2);transform:scale(.2)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes am-scale-down{0%{opacity:0;-webkit-transform:scale(1.8);transform:scale(1.8)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes am-scale-down{0%{opacity:0;-webkit-transform:scale(1.8);transform:scale(1.8)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes am-slide-top{0%{opacity:0;-webkit-transform:translateY(-100%);transform:translateY(-100%)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes am-slide-top{0%{opacity:0;-webkit-transform:translateY(-100%);transform:translateY(-100%)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes am-slide-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes am-slide-bottom{0%{opacity:0;-webkit-transform:translateY(100%);transform:translateY(100%)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes am-slide-left{0%{opacity:0;-webkit-transform:translateX(-100%);transform:translateX(-100%)}100%{opacity:1;-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes am-slide-left{0%{opacity:0;-webkit-transform:translateX(-100%);transform:translateX(-100%)}100%{opacity:1;-webkit-transform:translateX(0);transform:translateX(0)}}@-webkit-keyframes am-slide-right{0%{opacity:0;-webkit-transform:translateX(100%);transform:translateX(100%)}100%{opacity:1;-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes am-slide-right{0%{opacity:0;-webkit-transform:translateX(100%);transform:translateX(100%)}100%{opacity:1;-webkit-transform:translateX(0);transform:translateX(0)}}@-webkit-keyframes am-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%{-webkit-transform:translateX(-9px);transform:translateX(-9px)}20%{-webkit-transform:translateX(8px);transform:translateX(8px)}30%{-webkit-transform:translateX(-7px);transform:translateX(-7px)}40%{-webkit-transform:translateX(6px);transform:translateX(6px)}50%{-webkit-transform:translateX(-5px);transform:translateX(-5px)}60%{-webkit-transform:translateX(4px);transform:translateX(4px)}70%{-webkit-transform:translateX(-3px);transform:translateX(-3px)}80%{-webkit-transform:translateX(2px);transform:translateX(2px)}90%{-webkit-transform:translateX(-1px);transform:translateX(-1px)}}@keyframes am-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%{-webkit-transform:translateX(-9px);transform:translateX(-9px)}20%{-webkit-transform:translateX(8px);transform:translateX(8px)}30%{-webkit-transform:translateX(-7px);transform:translateX(-7px)}40%{-webkit-transform:translateX(6px);transform:translateX(6px)}50%{-webkit-transform:translateX(-5px);transform:translateX(-5px)}60%{-webkit-transform:translateX(4px);transform:translateX(4px)}70%{-webkit-transform:translateX(-3px);transform:translateX(-3px)}80%{-webkit-transform:translateX(2px);transform:translateX(2px)}90%{-webkit-transform:translateX(-1px);transform:translateX(-1px)}}@-webkit-keyframes am-slide-top-fixed{0%{opacity:0;-webkit-transform:translateY(-10px);transform:translateY(-10px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes am-slide-top-fixed{0%{opacity:0;-webkit-transform:translateY(-10px);transform:translateY(-10px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes am-slide-bottom-fixed{0%{opacity:0;-webkit-transform:translateY(10px);transform:translateY(10px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes am-slide-bottom-fixed{0%{opacity:0;-webkit-transform:translateY(10px);transform:translateY(10px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@-webkit-keyframes am-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes am-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@-webkit-keyframes am-right-spring{0%{-webkit-transform:translateX(0);transform:translateX(0)}50%{-webkit-transform:translateX(-20%);transform:translateX(-20%)}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes am-right-spring{0%{-webkit-transform:translateX(0);transform:translateX(0)}50%{-webkit-transform:translateX(-20%);transform:translateX(-20%)}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@-webkit-keyframes am-left-spring{0%{-webkit-transform:translateX(0);transform:translateX(0)}50%{-webkit-transform:translateX(20%);transform:translateX(20%)}100%{-webkit-transform:translateX(0);transform:translateX(0)}}@keyframes am-left-spring{0%{-webkit-transform:translateX(0);transform:translateX(0)}50%{-webkit-transform:translateX(20%);transform:translateX(20%)}100%{-webkit-transform:translateX(0);transform:translateX(0)}}.am-article:after,.am-article:before{content:" ";display:table}.am-article:after{clear:both}.am-article>:last-child{margin-bottom:0}.am-article+.am-article{margin-top:2.4rem}.am-article-title{font-size:2.8rem;line-height:1.15;font-weight:400}.am-article-title a{color:inherit;text-decoration:none}.am-article-meta{font-size:1.2rem;line-height:1.5;color:#999}.am-article-lead{color:#666;font-size:1.4rem;line-height:1.5;border:1px solid #dedede;border-radius:2px;background:#f9f9f9;padding:10px}.am-article-divider{margin-bottom:2.4rem;border-color:#eee}*+.am-article-divider{margin-top:2.4rem}.am-article-bd blockquote{font-family:Georgia,"Times New Roman",Times,Kai,"Kaiti SC",KaiTi,BiauKai,FontAwesome,serif}.am-article-bd img{display:block;max-width:100%}.am-badge{display:inline-block;min-width:10px;padding:.25em .625em;font-size:1.2rem;font-weight:700;color:#fff;line-height:1;vertical-align:baseline;white-space:nowrap;text-align:center;background-color:#999;border-radius:0}.am-badge:empty{display:none}.am-badge.am-square{border-radius:0}.am-badge.am-radius{border-radius:2px}.am-badge.am-round{border-radius:1000px}a.am-badge:focus,a.am-badge:hover{color:#fff;text-decoration:none;cursor:pointer}.am-badge-primary{background-color:#0e90d2}.am-badge-secondary{background-color:#3bb4f2}.am-badge-success{background-color:#5eb95e}.am-badge-warning{background-color:#F37B1D}.am-badge-danger{background-color:#dd514c}.am-comment:after,.am-comment:before{content:" ";display:table}.am-comment:after{clear:both}.am-comment-avatar{float:left;width:32px;height:32px;border-radius:50%;border:1px solid transparent}@media only screen and (min-width:641px){.am-comment-avatar{width:48px;height:48px}}.am-comment-main{position:relative;margin-left:42px;border:1px solid #dedede;border-radius:0}.am-comment-main:after,.am-comment-main:before{position:absolute;top:10px;left:-8px;right:100%;width:0;height:0;display:block;content:" ";border-color:transparent;border-style:solid solid outset;border-width:8px 8px 8px 0;pointer-events:none}.am-comment-main:before{border-right-color:#dedede;z-index:1}.am-comment-main:after{border-right-color:#f8f8f8;margin-left:1px;z-index:2}@media only screen and (min-width:641px){.am-comment-main{margin-left:63px}}.am-comment-hd{background:#f8f8f8;border-bottom:1px solid #eee;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.am-comment-title{margin:0 0 8px 0;font-size:1.6rem;line-height:1.2}.am-comment-meta{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;padding:10px 15px;font-size:13px;color:#999;line-height:1.2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.am-comment-meta a{color:#999}.am-comment-author{font-weight:700;color:#999}.am-comment-bd{padding:15px;overflow:hidden}.am-comment-bd>:last-child{margin-bottom:0}.am-comment-footer{padding:0 15px 5px}.am-comment-footer .am-comment-actions a+a{margin-left:5px}.am-comment-actions{font-size:13px;color:#999}.am-comment-actions a{display:inline-block;padding:10px 5px;line-height:1;color:#999;opacity:.7}.am-comment-actions a:hover{color:#0e90d2;opacity:1}.am-comment-hd .am-comment-actions{padding-right:.5rem}.am-comment-flip .am-comment-avatar{float:right}.am-comment-flip .am-comment-main{margin-left:auto;margin-right:42px}@media only screen and (min-width:641px){.am-comment-flip .am-comment-main{margin-right:63px}}.am-comment-flip .am-comment-main:after,.am-comment-flip .am-comment-main:before{left:auto;right:-8px;border-width:8px 0 8px 8px}.am-comment-flip .am-comment-main:before{border-left-color:#dedede}.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8;margin-right:1px;margin-left:auto}.am-comment-primary .am-comment-avatar{border-color:#0e90d2}.am-comment-primary .am-comment-main{border-color:#0e90d2}.am-comment-primary .am-comment-main:before{border-right-color:#0e90d2}.am-comment-primary.am-comment-flip .am-comment-main:before{border-left-color:#0e90d2;border-right-color:transparent}.am-comment-primary.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8}.am-comment-highlight .am-comment-avatar,.am-comment-secondary .am-comment-avatar{border-color:#3bb4f2}.am-comment-highlight .am-comment-main,.am-comment-secondary .am-comment-main{border-color:#3bb4f2}.am-comment-highlight .am-comment-main:before,.am-comment-secondary .am-comment-main:before{border-right-color:#3bb4f2}.am-comment-highlight.am-comment-flip .am-comment-main:before,.am-comment-secondary.am-comment-flip .am-comment-main:before{border-left-color:#3bb4f2;border-right-color:transparent}.am-comment-highlight.am-comment-flip .am-comment-main:after,.am-comment-secondary.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8}.am-comment-success .am-comment-avatar{border-color:#5eb95e}.am-comment-success .am-comment-main{border-color:#5eb95e}.am-comment-success .am-comment-main:before{border-right-color:#5eb95e}.am-comment-success.am-comment-flip .am-comment-main:before{border-left-color:#5eb95e;border-right-color:transparent}.am-comment-success.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8}.am-comment-warning .am-comment-avatar{border-color:#F37B1D}.am-comment-warning .am-comment-main{border-color:#F37B1D}.am-comment-warning .am-comment-main:before{border-right-color:#F37B1D}.am-comment-warning.am-comment-flip .am-comment-main:before{border-left-color:#F37B1D;border-right-color:transparent}.am-comment-warning.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8}.am-comment-danger .am-comment-avatar{border-color:#dd514c}.am-comment-danger .am-comment-main{border-color:#dd514c}.am-comment-danger .am-comment-main:before{border-right-color:#dd514c}.am-comment-danger.am-comment-flip .am-comment-main:before{border-left-color:#dd514c;border-right-color:transparent}.am-comment-danger.am-comment-flip .am-comment-main:after{border-left-color:#f8f8f8}.am-comments-list{padding:0;list-style:none}.am-comments-list .am-comment{margin:1.6rem 0 0 0;list-style:none}@media only screen and (min-width:641px){.am-comments-list-flip .am-comment-main{margin-right:64px}.am-comments-list-flip .am-comment-flip .am-comment-main{margin-left:64px}}.am-btn-group,.am-btn-group-stacked{position:relative;display:inline-block;vertical-align:middle}.am-btn-group-stacked>.am-btn,.am-btn-group>.am-btn{position:relative;float:left}.am-btn-group-stacked>.am-btn.active,.am-btn-group-stacked>.am-btn:active,.am-btn-group-stacked>.am-btn:focus,.am-btn-group-stacked>.am-btn:hover,.am-btn-group>.am-btn.active,.am-btn-group>.am-btn:active,.am-btn-group>.am-btn:focus,.am-btn-group>.am-btn:hover{z-index:2}.am-btn-group-stacked>.am-btn:focus,.am-btn-group>.am-btn:focus{outline:0}.am-btn-group .am-btn+.am-btn,.am-btn-group .am-btn+.am-btn-group,.am-btn-group .am-btn-group+.am-btn,.am-btn-group .am-btn-group+.am-btn-group{margin-left:-1px}.am-btn-toolbar{margin-left:-5px}.am-btn-toolbar:after,.am-btn-toolbar:before{content:" ";display:table}.am-btn-toolbar:after{clear:both}.am-btn-toolbar .am-btn-group,.am-btn-toolbar .am-input-group{float:left}.am-btn-toolbar>.am-btn,.am-btn-toolbar>.am-btn-group,.am-btn-toolbar>.am-input-group{margin-left:5px}.am-btn-group>.am-btn:not(:first-child):not(:last-child):not(.am-dropdown-toggle){border-radius:0}.am-btn-group>.am-btn:first-child{margin-left:0}.am-btn-group>.am-btn:first-child:not(:last-child):not(.am-dropdown-toggle){border-bottom-right-radius:0;border-top-right-radius:0}.am-btn-group>.am-btn:last-child:not(:first-child),.am-btn-group>.am-dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.am-btn-group>.am-btn-group{float:left}.am-btn-group>.am-btn-group:not(:first-child):not(:last-child)>.am-btn{border-radius:0}.am-btn-group>.am-btn-group:first-child>.am-btn:last-child,.am-btn-group>.am-btn-group:first-child>.am-dropdown-toggle{border-bottom-right-radius:0;border-top-right-radius:0}.am-btn-group>.am-btn-group:last-child>.am-btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.am-btn-group-xs>.am-btn{font-size:1.2rem}.am-btn-group-sm>.am-btn{font-size:1.4rem}.am-btn-group-lg>.am-btn{font-size:1.8rem}.am-btn-group-stacked>.am-btn,.am-btn-group-stacked>.am-btn-group,.am-btn-group-stacked>.am-btn-group>.am-btn{display:block;float:none;width:100%;max-width:100%}.am-btn-group-stacked>.am-btn-group:after,.am-btn-group-stacked>.am-btn-group:before{content:" ";display:table}.am-btn-group-stacked>.am-btn-group:after{clear:both}.am-btn-group-stacked>.am-btn-group>.am-btn{float:none}.am-btn-group-stacked>.am-btn+.am-btn,.am-btn-group-stacked>.am-btn+.am-btn-group,.am-btn-group-stacked>.am-btn-group+.am-btn,.am-btn-group-stacked>.am-btn-group+.am-btn-group{margin-top:-1px;margin-left:0}.am-btn-group-stacked>.am-btn:not(:first-child):not(:last-child){border-radius:0}.am-btn-group-stacked>.am-btn:first-child:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.am-btn-group-stacked>.am-btn:last-child:not(:first-child){border-bottom-left-radius:0;border-top-right-radius:0;border-top-left-radius:0}.am-btn-group-stacked>.am-btn-group:not(:first-child):not(:last-child)>.am-btn{border-radius:0}.am-btn-group-stacked>.am-btn-group:first-child:not(:last-child)>.am-btn:last-child,.am-btn-group-stacked>.am-btn-group:first-child:not(:last-child)>.am-dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.am-btn-group-stacked>.am-btn-group:last-child:not(:first-child)>.am-btn:first-child{border-top-right-radius:0;border-top-left-radius:0}.am-btn-group-justify{display:table;table-layout:fixed;border-collapse:separate;width:100%}.am-btn-group-justify>.am-btn,.am-btn-group-justify>.am-btn-group{float:none;display:table-cell;width:1%}.am-btn-group-justify>.am-btn-group .am-btn{width:100%}.lte9 .am-btn-group-justify{display:table;table-layout:fixed;border-collapse:separate}.lte9 .am-btn-group-justify>.am-btn,.lte9 .am-btn-group-justify>.am-btn-group{float:none;display:table-cell;width:1%}.am-btn-group .am-dropdown{float:left;margin-left:-1px}.am-btn-group .am-dropdown>.am-btn{border-bottom-left-radius:0;border-top-left-radius:0}.am-btn-group .am-active .am-dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.am-btn-group .am-active .am-dropdown-toggle.am-btn-link{-webkit-box-shadow:none;box-shadow:none}.am-btn-group .am-active .am-dropdown-toggle,.am-btn-group .am-dropdown-toggle:active{outline:0}.am-btn-group-check>.am-btn>input[type=checkbox],.am-btn-group-check>.am-btn>input[type=radio],[data-am-button]>.am-btn>input[type=checkbox],[data-am-button]>.am-btn>input[type=radio]{position:absolute;z-index:-1;opacity:0}.am-close{display:inline-block;text-align:center;width:24px;font-size:20px;font-weight:700;line-height:24px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;-webkit-transition:all .3s;transition:all .3s}.am-close:focus,.am-close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.5;outline:0}.am-close[class*=am-icon-]{font-size:16px}button.am-close{padding:0;cursor:pointer;background:0 0;border:0;-webkit-appearance:none}a.am-close:hover{color:inherit;text-decoration:none;cursor:pointer}.am-close-alt{border-radius:50%;background:#eee;opacity:.7;-webkit-box-shadow:0 0 0 1px rgba(0,0,0,.25);box-shadow:0 0 0 1px rgba(0,0,0,.25)}.am-close-alt:focus,.am-close-alt:hover{opacity:1}.am-close-spin:hover{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}@font-face{font-family:FontAwesome;src:url(../fonts/fontawesome-webfont.eot?v=4.6.3);src:url(../fonts/fontawesome-webfont.eot?#iefix&v=4.6.3) format('embedded-opentype'),url(../fonts/fontawesome-webfont.woff2?v=4.6.3) format('woff2'),url(../fonts/fontawesome-webfont.woff?v=4.6.3) format('woff'),url(../fonts/fontawesome-webfont.ttf?v=4.6.3) format('truetype');font-weight:400;font-style:normal}[class*=am-icon-]{display:inline-block;font-style:normal}[class*=am-icon-]:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.am-icon-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}[class*=am-icon-].am-fl{margin-right:.3em}[class*=am-icon-].am-fr{margin-left:.3em}.am-icon-sm:before{font-size:150%;vertical-align:-10%}.am-icon-md:before{font-size:200%;vertical-align:-16%}.am-icon-lg:before{font-size:250%;vertical-align:-22%}.am-icon-btn{-webkit-box-sizing:border-box;box-sizing:border-box;display:inline-block;width:48px;height:48px;font-size:24px;line-height:48px;border-radius:50%;background-color:#eee;color:#555;text-align:center}.am-icon-btn:focus,.am-icon-btn:hover{background-color:#f5f5f5;color:#333;text-decoration:none;outline:0}.am-icon-btn:active{background-color:#ddd;color:#333}.am-icon-btn.am-danger,.am-icon-btn.am-primary,.am-icon-btn.am-secondary,.am-icon-btn.am-success,.am-icon-btn.am-warning{color:#fff}.am-icon-btn.am-primary{background-color:#0e90d2}.am-icon-btn.am-secondary{background-color:#3bb4f2}.am-icon-btn.am-success{background-color:#5eb95e}.am-icon-btn.am-warning{background-color:#F37B1D}.am-icon-btn.am-danger{background-color:#dd514c}.am-icon-btn-sm{width:32px;height:32px;font-size:16px;line-height:32px}.am-icon-btn-lg{width:64px;height:64px;font-size:28px;line-height:64px}.am-icon-fw{width:1.25em;text-align:center}.am-icon-glass:before{content:"\f000"}.am-icon-music:before{content:"\f001"}.am-icon-search:before{content:"\f002"}.am-icon-envelope-o:before{content:"\f003"}.am-icon-heart:before{content:"\f004"}.am-icon-star:before{content:"\f005"}.am-icon-star-o:before{content:"\f006"}.am-icon-user:before{content:"\f007"}.am-icon-film:before{content:"\f008"}.am-icon-th-large:before{content:"\f009"}.am-icon-th:before{content:"\f00a"}.am-icon-th-list:before{content:"\f00b"}.am-icon-check:before{content:"\f00c"}.am-icon-close:before,.am-icon-remove:before,.am-icon-times:before{content:"\f00d"}.am-icon-search-plus:before{content:"\f00e"}.am-icon-search-minus:before{content:"\f010"}.am-icon-power-off:before{content:"\f011"}.am-icon-signal:before{content:"\f012"}.am-icon-cog:before,.am-icon-gear:before{content:"\f013"}.am-icon-trash-o:before{content:"\f014"}.am-icon-home:before{content:"\f015"}.am-icon-file-o:before{content:"\f016"}.am-icon-clock-o:before{content:"\f017"}.am-icon-road:before{content:"\f018"}.am-icon-download:before{content:"\f019"}.am-icon-arrow-circle-o-down:before{content:"\f01a"}.am-icon-arrow-circle-o-up:before{content:"\f01b"}.am-icon-inbox:before{content:"\f01c"}.am-icon-play-circle-o:before{content:"\f01d"}.am-icon-repeat:before,.am-icon-rotate-right:before{content:"\f01e"}.am-icon-refresh:before{content:"\f021"}.am-icon-list-alt:before{content:"\f022"}.am-icon-lock:before{content:"\f023"}.am-icon-flag:before{content:"\f024"}.am-icon-headphones:before{content:"\f025"}.am-icon-volume-off:before{content:"\f026"}.am-icon-volume-down:before{content:"\f027"}.am-icon-volume-up:before{content:"\f028"}.am-icon-qrcode:before{content:"\f029"}.am-icon-barcode:before{content:"\f02a"}.am-icon-tag:before{content:"\f02b"}.am-icon-tags:before{content:"\f02c"}.am-icon-book:before{content:"\f02d"}.am-icon-bookmark:before{content:"\f02e"}.am-icon-print:before{content:"\f02f"}.am-icon-camera:before{content:"\f030"}.am-icon-font:before{content:"\f031"}.am-icon-bold:before{content:"\f032"}.am-icon-italic:before{content:"\f033"}.am-icon-text-height:before{content:"\f034"}.am-icon-text-width:before{content:"\f035"}.am-icon-align-left:before{content:"\f036"}.am-icon-align-center:before{content:"\f037"}.am-icon-align-right:before{content:"\f038"}.am-icon-align-justify:before{content:"\f039"}.am-icon-list:before{content:"\f03a"}.am-icon-dedent:before,.am-icon-outdent:before{content:"\f03b"}.am-icon-indent:before{content:"\f03c"}.am-icon-video-camera:before{content:"\f03d"}.am-icon-image:before,.am-icon-photo:before,.am-icon-picture-o:before{content:"\f03e"}.am-icon-pencil:before{content:"\f040"}.am-icon-map-marker:before{content:"\f041"}.am-icon-adjust:before{content:"\f042"}.am-icon-tint:before{content:"\f043"}.am-icon-edit:before,.am-icon-pencil-square-o:before{content:"\f044"}.am-icon-share-square-o:before{content:"\f045"}.am-icon-check-square-o:before{content:"\f046"}.am-icon-arrows:before{content:"\f047"}.am-icon-step-backward:before{content:"\f048"}.am-icon-fast-backward:before{content:"\f049"}.am-icon-backward:before{content:"\f04a"}.am-icon-play:before{content:"\f04b"}.am-icon-pause:before{content:"\f04c"}.am-icon-stop:before{content:"\f04d"}.am-icon-forward:before{content:"\f04e"}.am-icon-fast-forward:before{content:"\f050"}.am-icon-step-forward:before{content:"\f051"}.am-icon-eject:before{content:"\f052"}.am-icon-chevron-left:before{content:"\f053"}.am-icon-chevron-right:before{content:"\f054"}.am-icon-plus-circle:before{content:"\f055"}.am-icon-minus-circle:before{content:"\f056"}.am-icon-times-circle:before{content:"\f057"}.am-icon-check-circle:before{content:"\f058"}.am-icon-question-circle:before{content:"\f059"}.am-icon-info-circle:before{content:"\f05a"}.am-icon-crosshairs:before{content:"\f05b"}.am-icon-times-circle-o:before{content:"\f05c"}.am-icon-check-circle-o:before{content:"\f05d"}.am-icon-ban:before{content:"\f05e"}.am-icon-arrow-left:before{content:"\f060"}.am-icon-arrow-right:before{content:"\f061"}.am-icon-arrow-up:before{content:"\f062"}.am-icon-arrow-down:before{content:"\f063"}.am-icon-mail-forward:before,.am-icon-share:before{content:"\f064"}.am-icon-expand:before{content:"\f065"}.am-icon-compress:before{content:"\f066"}.am-icon-plus:before{content:"\f067"}.am-icon-minus:before{content:"\f068"}.am-icon-asterisk:before{content:"\f069"}.am-icon-exclamation-circle:before{content:"\f06a"}.am-icon-gift:before{content:"\f06b"}.am-icon-leaf:before{content:"\f06c"}.am-icon-fire:before{content:"\f06d"}.am-icon-eye:before{content:"\f06e"}.am-icon-eye-slash:before{content:"\f070"}.am-icon-exclamation-triangle:before,.am-icon-warning:before{content:"\f071"}.am-icon-plane:before{content:"\f072"}.am-icon-calendar:before{content:"\f073"}.am-icon-random:before{content:"\f074"}.am-icon-comment:before{content:"\f075"}.am-icon-magnet:before{content:"\f076"}.am-icon-chevron-up:before{content:"\f077"}.am-icon-chevron-down:before{content:"\f078"}.am-icon-retweet:before{content:"\f079"}.am-icon-shopping-cart:before{content:"\f07a"}.am-icon-folder:before{content:"\f07b"}.am-icon-folder-open:before{content:"\f07c"}.am-icon-arrows-v:before{content:"\f07d"}.am-icon-arrows-h:before{content:"\f07e"}.am-icon-bar-chart-o:before,.am-icon-bar-chart:before{content:"\f080"}.am-icon-twitter-square:before{content:"\f081"}.am-icon-facebook-square:before{content:"\f082"}.am-icon-camera-retro:before{content:"\f083"}.am-icon-key:before{content:"\f084"}.am-icon-cogs:before,.am-icon-gears:before{content:"\f085"}.am-icon-comments:before{content:"\f086"}.am-icon-thumbs-o-up:before{content:"\f087"}.am-icon-thumbs-o-down:before{content:"\f088"}.am-icon-star-half:before{content:"\f089"}.am-icon-heart-o:before{content:"\f08a"}.am-icon-sign-out:before{content:"\f08b"}.am-icon-linkedin-square:before{content:"\f08c"}.am-icon-thumb-tack:before{content:"\f08d"}.am-icon-external-link:before{content:"\f08e"}.am-icon-sign-in:before{content:"\f090"}.am-icon-trophy:before{content:"\f091"}.am-icon-github-square:before{content:"\f092"}.am-icon-upload:before{content:"\f093"}.am-icon-lemon-o:before{content:"\f094"}.am-icon-phone:before{content:"\f095"}.am-icon-square-o:before{content:"\f096"}.am-icon-bookmark-o:before{content:"\f097"}.am-icon-phone-square:before{content:"\f098"}.am-icon-twitter:before{content:"\f099"}.am-icon-facebook-f:before,.am-icon-facebook:before{content:"\f09a"}.am-icon-github:before{content:"\f09b"}.am-icon-unlock:before{content:"\f09c"}.am-icon-credit-card:before{content:"\f09d"}.am-icon-feed:before,.am-icon-rss:before{content:"\f09e"}.am-icon-hdd-o:before{content:"\f0a0"}.am-icon-bullhorn:before{content:"\f0a1"}.am-icon-bell:before{content:"\f0f3"}.am-icon-certificate:before{content:"\f0a3"}.am-icon-hand-o-right:before{content:"\f0a4"}.am-icon-hand-o-left:before{content:"\f0a5"}.am-icon-hand-o-up:before{content:"\f0a6"}.am-icon-hand-o-down:before{content:"\f0a7"}.am-icon-arrow-circle-left:before{content:"\f0a8"}.am-icon-arrow-circle-right:before{content:"\f0a9"}.am-icon-arrow-circle-up:before{content:"\f0aa"}.am-icon-arrow-circle-down:before{content:"\f0ab"}.am-icon-globe:before{content:"\f0ac"}.am-icon-wrench:before{content:"\f0ad"}.am-icon-tasks:before{content:"\f0ae"}.am-icon-filter:before{content:"\f0b0"}.am-icon-briefcase:before{content:"\f0b1"}.am-icon-arrows-alt:before{content:"\f0b2"}.am-icon-group:before,.am-icon-users:before{content:"\f0c0"}.am-icon-chain:before,.am-icon-link:before{content:"\f0c1"}.am-icon-cloud:before{content:"\f0c2"}.am-icon-flask:before{content:"\f0c3"}.am-icon-cut:before,.am-icon-scissors:before{content:"\f0c4"}.am-icon-copy:before,.am-icon-files-o:before{content:"\f0c5"}.am-icon-paperclip:before{content:"\f0c6"}.am-icon-floppy-o:before,.am-icon-save:before{content:"\f0c7"}.am-icon-square:before{content:"\f0c8"}.am-icon-bars:before,.am-icon-navicon:before,.am-icon-reorder:before{content:"\f0c9"}.am-icon-list-ul:before{content:"\f0ca"}.am-icon-list-ol:before{content:"\f0cb"}.am-icon-strikethrough:before{content:"\f0cc"}.am-icon-underline:before{content:"\f0cd"}.am-icon-table:before{content:"\f0ce"}.am-icon-magic:before{content:"\f0d0"}.am-icon-truck:before{content:"\f0d1"}.am-icon-pinterest:before{content:"\f0d2"}.am-icon-pinterest-square:before{content:"\f0d3"}.am-icon-google-plus-square:before{content:"\f0d4"}.am-icon-google-plus:before{content:"\f0d5"}.am-icon-money:before{content:"\f0d6"}.am-icon-caret-down:before{content:"\f0d7"}.am-icon-caret-up:before{content:"\f0d8"}.am-icon-caret-left:before{content:"\f0d9"}.am-icon-caret-right:before{content:"\f0da"}.am-icon-columns:before{content:"\f0db"}.am-icon-sort:before,.am-icon-unsorted:before{content:"\f0dc"}.am-icon-sort-desc:before,.am-icon-sort-down:before{content:"\f0dd"}.am-icon-sort-asc:before,.am-icon-sort-up:before{content:"\f0de"}.am-icon-envelope:before{content:"\f0e0"}.am-icon-linkedin:before{content:"\f0e1"}.am-icon-rotate-left:before,.am-icon-undo:before{content:"\f0e2"}.am-icon-gavel:before,.am-icon-legal:before{content:"\f0e3"}.am-icon-dashboard:before,.am-icon-tachometer:before{content:"\f0e4"}.am-icon-comment-o:before{content:"\f0e5"}.am-icon-comments-o:before{content:"\f0e6"}.am-icon-bolt:before,.am-icon-flash:before{content:"\f0e7"}.am-icon-sitemap:before{content:"\f0e8"}.am-icon-umbrella:before{content:"\f0e9"}.am-icon-clipboard:before,.am-icon-paste:before{content:"\f0ea"}.am-icon-lightbulb-o:before{content:"\f0eb"}.am-icon-exchange:before{content:"\f0ec"}.am-icon-cloud-download:before{content:"\f0ed"}.am-icon-cloud-upload:before{content:"\f0ee"}.am-icon-user-md:before{content:"\f0f0"}.am-icon-stethoscope:before{content:"\f0f1"}.am-icon-suitcase:before{content:"\f0f2"}.am-icon-bell-o:before{content:"\f0a2"}.am-icon-coffee:before{content:"\f0f4"}.am-icon-cutlery:before{content:"\f0f5"}.am-icon-file-text-o:before{content:"\f0f6"}.am-icon-building-o:before{content:"\f0f7"}.am-icon-hospital-o:before{content:"\f0f8"}.am-icon-ambulance:before{content:"\f0f9"}.am-icon-medkit:before{content:"\f0fa"}.am-icon-fighter-jet:before{content:"\f0fb"}.am-icon-beer:before{content:"\f0fc"}.am-icon-h-square:before{content:"\f0fd"}.am-icon-plus-square:before{content:"\f0fe"}.am-icon-angle-double-left:before{content:"\f100"}.am-icon-angle-double-right:before{content:"\f101"}.am-icon-angle-double-up:before{content:"\f102"}.am-icon-angle-double-down:before{content:"\f103"}.am-icon-angle-left:before{content:"\f104"}.am-icon-angle-right:before{content:"\f105"}.am-icon-angle-up:before{content:"\f106"}.am-icon-angle-down:before{content:"\f107"}.am-icon-desktop:before{content:"\f108"}.am-icon-laptop:before{content:"\f109"}.am-icon-tablet:before{content:"\f10a"}.am-icon-mobile-phone:before,.am-icon-mobile:before{content:"\f10b"}.am-icon-circle-o:before{content:"\f10c"}.am-icon-quote-left:before{content:"\f10d"}.am-icon-quote-right:before{content:"\f10e"}.am-icon-spinner:before{content:"\f110"}.am-icon-circle:before{content:"\f111"}.am-icon-mail-reply:before,.am-icon-reply:before{content:"\f112"}.am-icon-github-alt:before{content:"\f113"}.am-icon-folder-o:before{content:"\f114"}.am-icon-folder-open-o:before{content:"\f115"}.am-icon-smile-o:before{content:"\f118"}.am-icon-frown-o:before{content:"\f119"}.am-icon-meh-o:before{content:"\f11a"}.am-icon-gamepad:before{content:"\f11b"}.am-icon-keyboard-o:before{content:"\f11c"}.am-icon-flag-o:before{content:"\f11d"}.am-icon-flag-checkered:before{content:"\f11e"}.am-icon-terminal:before{content:"\f120"}.am-icon-code:before{content:"\f121"}.am-icon-mail-reply-all:before,.am-icon-reply-all:before{content:"\f122"}.am-icon-star-half-empty:before,.am-icon-star-half-full:before,.am-icon-star-half-o:before{content:"\f123"}.am-icon-location-arrow:before{content:"\f124"}.am-icon-crop:before{content:"\f125"}.am-icon-code-fork:before{content:"\f126"}.am-icon-chain-broken:before,.am-icon-unlink:before{content:"\f127"}.am-icon-question:before{content:"\f128"}.am-icon-info:before{content:"\f129"}.am-icon-exclamation:before{content:"\f12a"}.am-icon-superscript:before{content:"\f12b"}.am-icon-subscript:before{content:"\f12c"}.am-icon-eraser:before{content:"\f12d"}.am-icon-puzzle-piece:before{content:"\f12e"}.am-icon-microphone:before{content:"\f130"}.am-icon-microphone-slash:before{content:"\f131"}.am-icon-shield:before{content:"\f132"}.am-icon-calendar-o:before{content:"\f133"}.am-icon-fire-extinguisher:before{content:"\f134"}.am-icon-rocket:before{content:"\f135"}.am-icon-maxcdn:before{content:"\f136"}.am-icon-chevron-circle-left:before{content:"\f137"}.am-icon-chevron-circle-right:before{content:"\f138"}.am-icon-chevron-circle-up:before{content:"\f139"}.am-icon-chevron-circle-down:before{content:"\f13a"}.am-icon-html5:before{content:"\f13b"}.am-icon-css3:before{content:"\f13c"}.am-icon-anchor:before{content:"\f13d"}.am-icon-unlock-alt:before{content:"\f13e"}.am-icon-bullseye:before{content:"\f140"}.am-icon-ellipsis-h:before{content:"\f141"}.am-icon-ellipsis-v:before{content:"\f142"}.am-icon-rss-square:before{content:"\f143"}.am-icon-play-circle:before{content:"\f144"}.am-icon-ticket:before{content:"\f145"}.am-icon-minus-square:before{content:"\f146"}.am-icon-minus-square-o:before{content:"\f147"}.am-icon-level-up:before{content:"\f148"}.am-icon-level-down:before{content:"\f149"}.am-icon-check-square:before{content:"\f14a"}.am-icon-pencil-square:before{content:"\f14b"}.am-icon-external-link-square:before{content:"\f14c"}.am-icon-share-square:before{content:"\f14d"}.am-icon-compass:before{content:"\f14e"}.am-icon-caret-square-o-down:before,.am-icon-toggle-down:before{content:"\f150"}.am-icon-caret-square-o-up:before,.am-icon-toggle-up:before{content:"\f151"}.am-icon-caret-square-o-right:before,.am-icon-toggle-right:before{content:"\f152"}.am-icon-eur:before,.am-icon-euro:before{content:"\f153"}.am-icon-gbp:before{content:"\f154"}.am-icon-dollar:before,.am-icon-usd:before{content:"\f155"}.am-icon-inr:before,.am-icon-rupee:before{content:"\f156"}.am-icon-cny:before,.am-icon-jpy:before,.am-icon-rmb:before,.am-icon-yen:before{content:"\f157"}.am-icon-rouble:before,.am-icon-rub:before,.am-icon-ruble:before{content:"\f158"}.am-icon-krw:before,.am-icon-won:before{content:"\f159"}.am-icon-bitcoin:before,.am-icon-btc:before{content:"\f15a"}.am-icon-file:before{content:"\f15b"}.am-icon-file-text:before{content:"\f15c"}.am-icon-sort-alpha-asc:before{content:"\f15d"}.am-icon-sort-alpha-desc:before{content:"\f15e"}.am-icon-sort-amount-asc:before{content:"\f160"}.am-icon-sort-amount-desc:before{content:"\f161"}.am-icon-sort-numeric-asc:before{content:"\f162"}.am-icon-sort-numeric-desc:before{content:"\f163"}.am-icon-thumbs-up:before{content:"\f164"}.am-icon-thumbs-down:before{content:"\f165"}.am-icon-youtube-square:before{content:"\f166"}.am-icon-youtube:before{content:"\f167"}.am-icon-xing:before{content:"\f168"}.am-icon-xing-square:before{content:"\f169"}.am-icon-youtube-play:before{content:"\f16a"}.am-icon-dropbox:before{content:"\f16b"}.am-icon-stack-overflow:before{content:"\f16c"}.am-icon-instagram:before{content:"\f16d"}.am-icon-flickr:before{content:"\f16e"}.am-icon-adn:before{content:"\f170"}.am-icon-bitbucket:before{content:"\f171"}.am-icon-bitbucket-square:before{content:"\f172"}.am-icon-tumblr:before{content:"\f173"}.am-icon-tumblr-square:before{content:"\f174"}.am-icon-long-arrow-down:before{content:"\f175"}.am-icon-long-arrow-up:before{content:"\f176"}.am-icon-long-arrow-left:before{content:"\f177"}.am-icon-long-arrow-right:before{content:"\f178"}.am-icon-apple:before{content:"\f179"}.am-icon-windows:before{content:"\f17a"}.am-icon-android:before{content:"\f17b"}.am-icon-linux:before{content:"\f17c"}.am-icon-dribbble:before{content:"\f17d"}.am-icon-skype:before{content:"\f17e"}.am-icon-foursquare:before{content:"\f180"}.am-icon-trello:before{content:"\f181"}.am-icon-female:before{content:"\f182"}.am-icon-male:before{content:"\f183"}.am-icon-gittip:before,.am-icon-gratipay:before{content:"\f184"}.am-icon-sun-o:before{content:"\f185"}.am-icon-moon-o:before{content:"\f186"}.am-icon-archive:before{content:"\f187"}.am-icon-bug:before{content:"\f188"}.am-icon-vk:before{content:"\f189"}.am-icon-weibo:before{content:"\f18a"}.am-icon-renren:before{content:"\f18b"}.am-icon-pagelines:before{content:"\f18c"}.am-icon-stack-exchange:before{content:"\f18d"}.am-icon-arrow-circle-o-right:before{content:"\f18e"}.am-icon-arrow-circle-o-left:before{content:"\f190"}.am-icon-caret-square-o-left:before,.am-icon-toggle-left:before{content:"\f191"}.am-icon-dot-circle-o:before{content:"\f192"}.am-icon-wheelchair:before{content:"\f193"}.am-icon-vimeo-square:before{content:"\f194"}.am-icon-try:before,.am-icon-turkish-lira:before{content:"\f195"}.am-icon-plus-square-o:before{content:"\f196"}.am-icon-space-shuttle:before{content:"\f197"}.am-icon-slack:before{content:"\f198"}.am-icon-envelope-square:before{content:"\f199"}.am-icon-wordpress:before{content:"\f19a"}.am-icon-openid:before{content:"\f19b"}.am-icon-bank:before,.am-icon-institution:before,.am-icon-university:before{content:"\f19c"}.am-icon-graduation-cap:before,.am-icon-mortar-board:before{content:"\f19d"}.am-icon-yahoo:before{content:"\f19e"}.am-icon-google:before{content:"\f1a0"}.am-icon-reddit:before{content:"\f1a1"}.am-icon-reddit-square:before{content:"\f1a2"}.am-icon-stumbleupon-circle:before{content:"\f1a3"}.am-icon-stumbleupon:before{content:"\f1a4"}.am-icon-delicious:before{content:"\f1a5"}.am-icon-digg:before{content:"\f1a6"}.am-icon-pied-piper-pp:before{content:"\f1a7"}.am-icon-pied-piper-alt:before{content:"\f1a8"}.am-icon-drupal:before{content:"\f1a9"}.am-icon-joomla:before{content:"\f1aa"}.am-icon-language:before{content:"\f1ab"}.am-icon-fax:before{content:"\f1ac"}.am-icon-building:before{content:"\f1ad"}.am-icon-child:before{content:"\f1ae"}.am-icon-paw:before{content:"\f1b0"}.am-icon-spoon:before{content:"\f1b1"}.am-icon-cube:before{content:"\f1b2"}.am-icon-cubes:before{content:"\f1b3"}.am-icon-behance:before{content:"\f1b4"}.am-icon-behance-square:before{content:"\f1b5"}.am-icon-steam:before{content:"\f1b6"}.am-icon-steam-square:before{content:"\f1b7"}.am-icon-recycle:before{content:"\f1b8"}.am-icon-automobile:before,.am-icon-car:before{content:"\f1b9"}.am-icon-cab:before,.am-icon-taxi:before{content:"\f1ba"}.am-icon-tree:before{content:"\f1bb"}.am-icon-spotify:before{content:"\f1bc"}.am-icon-deviantart:before{content:"\f1bd"}.am-icon-soundcloud:before{content:"\f1be"}.am-icon-database:before{content:"\f1c0"}.am-icon-file-pdf-o:before{content:"\f1c1"}.am-icon-file-word-o:before{content:"\f1c2"}.am-icon-file-excel-o:before{content:"\f1c3"}.am-icon-file-powerpoint-o:before{content:"\f1c4"}.am-icon-file-image-o:before,.am-icon-file-photo-o:before,.am-icon-file-picture-o:before{content:"\f1c5"}.am-icon-file-archive-o:before,.am-icon-file-zip-o:before{content:"\f1c6"}.am-icon-file-audio-o:before,.am-icon-file-sound-o:before{content:"\f1c7"}.am-icon-file-movie-o:before,.am-icon-file-video-o:before{content:"\f1c8"}.am-icon-file-code-o:before{content:"\f1c9"}.am-icon-vine:before{content:"\f1ca"}.am-icon-codepen:before{content:"\f1cb"}.am-icon-jsfiddle:before{content:"\f1cc"}.am-icon-life-bouy:before,.am-icon-life-buoy:before,.am-icon-life-ring:before,.am-icon-life-saver:before,.am-icon-support:before{content:"\f1cd"}.am-icon-circle-o-notch:before{content:"\f1ce"}.am-icon-ra:before,.am-icon-rebel:before,.am-icon-resistance:before{content:"\f1d0"}.am-icon-empire:before,.am-icon-ge:before{content:"\f1d1"}.am-icon-git-square:before{content:"\f1d2"}.am-icon-git:before{content:"\f1d3"}.am-icon-hacker-news:before,.am-icon-y-combinator-square:before,.am-icon-yc-square:before{content:"\f1d4"}.am-icon-tencent-weibo:before{content:"\f1d5"}.am-icon-qq:before{content:"\f1d6"}.am-icon-wechat:before,.am-icon-weixin:before{content:"\f1d7"}.am-icon-paper-plane:before,.am-icon-send:before{content:"\f1d8"}.am-icon-paper-plane-o:before,.am-icon-send-o:before{content:"\f1d9"}.am-icon-history:before{content:"\f1da"}.am-icon-circle-thin:before{content:"\f1db"}.am-icon-header:before{content:"\f1dc"}.am-icon-paragraph:before{content:"\f1dd"}.am-icon-sliders:before{content:"\f1de"}.am-icon-share-alt:before{content:"\f1e0"}.am-icon-share-alt-square:before{content:"\f1e1"}.am-icon-bomb:before{content:"\f1e2"}.am-icon-futbol-o:before,.am-icon-soccer-ball-o:before{content:"\f1e3"}.am-icon-tty:before{content:"\f1e4"}.am-icon-binoculars:before{content:"\f1e5"}.am-icon-plug:before{content:"\f1e6"}.am-icon-slideshare:before{content:"\f1e7"}.am-icon-twitch:before{content:"\f1e8"}.am-icon-yelp:before{content:"\f1e9"}.am-icon-newspaper-o:before{content:"\f1ea"}.am-icon-wifi:before{content:"\f1eb"}.am-icon-calculator:before{content:"\f1ec"}.am-icon-paypal:before{content:"\f1ed"}.am-icon-google-wallet:before{content:"\f1ee"}.am-icon-cc-visa:before{content:"\f1f0"}.am-icon-cc-mastercard:before{content:"\f1f1"}.am-icon-cc-discover:before{content:"\f1f2"}.am-icon-cc-amex:before{content:"\f1f3"}.am-icon-cc-paypal:before{content:"\f1f4"}.am-icon-cc-stripe:before{content:"\f1f5"}.am-icon-bell-slash:before{content:"\f1f6"}.am-icon-bell-slash-o:before{content:"\f1f7"}.am-icon-trash:before{content:"\f1f8"}.am-icon-copyright:before{content:"\f1f9"}.am-icon-at:before{content:"\f1fa"}.am-icon-eyedropper:before{content:"\f1fb"}.am-icon-paint-brush:before{content:"\f1fc"}.am-icon-birthday-cake:before{content:"\f1fd"}.am-icon-area-chart:before{content:"\f1fe"}.am-icon-pie-chart:before{content:"\f200"}.am-icon-line-chart:before{content:"\f201"}.am-icon-lastfm:before{content:"\f202"}.am-icon-lastfm-square:before{content:"\f203"}.am-icon-toggle-off:before{content:"\f204"}.am-icon-toggle-on:before{content:"\f205"}.am-icon-bicycle:before{content:"\f206"}.am-icon-bus:before{content:"\f207"}.am-icon-ioxhost:before{content:"\f208"}.am-icon-angellist:before{content:"\f209"}.am-icon-cc:before{content:"\f20a"}.am-icon-ils:before,.am-icon-shekel:before,.am-icon-sheqel:before{content:"\f20b"}.am-icon-meanpath:before{content:"\f20c"}.am-icon-buysellads:before{content:"\f20d"}.am-icon-connectdevelop:before{content:"\f20e"}.am-icon-dashcube:before{content:"\f210"}.am-icon-forumbee:before{content:"\f211"}.am-icon-leanpub:before{content:"\f212"}.am-icon-sellsy:before{content:"\f213"}.am-icon-shirtsinbulk:before{content:"\f214"}.am-icon-simplybuilt:before{content:"\f215"}.am-icon-skyatlas:before{content:"\f216"}.am-icon-cart-plus:before{content:"\f217"}.am-icon-cart-arrow-down:before{content:"\f218"}.am-icon-diamond:before{content:"\f219"}.am-icon-ship:before{content:"\f21a"}.am-icon-user-secret:before{content:"\f21b"}.am-icon-motorcycle:before{content:"\f21c"}.am-icon-street-view:before{content:"\f21d"}.am-icon-heartbeat:before{content:"\f21e"}.am-icon-venus:before{content:"\f221"}.am-icon-mars:before{content:"\f222"}.am-icon-mercury:before{content:"\f223"}.am-icon-intersex:before,.am-icon-transgender:before{content:"\f224"}.am-icon-transgender-alt:before{content:"\f225"}.am-icon-venus-double:before{content:"\f226"}.am-icon-mars-double:before{content:"\f227"}.am-icon-venus-mars:before{content:"\f228"}.am-icon-mars-stroke:before{content:"\f229"}.am-icon-mars-stroke-v:before{content:"\f22a"}.am-icon-mars-stroke-h:before{content:"\f22b"}.am-icon-neuter:before{content:"\f22c"}.am-icon-genderless:before{content:"\f22d"}.am-icon-facebook-official:before{content:"\f230"}.am-icon-pinterest-p:before{content:"\f231"}.am-icon-whatsapp:before{content:"\f232"}.am-icon-server:before{content:"\f233"}.am-icon-user-plus:before{content:"\f234"}.am-icon-user-times:before{content:"\f235"}.am-icon-bed:before,.am-icon-hotel:before{content:"\f236"}.am-icon-viacoin:before{content:"\f237"}.am-icon-train:before{content:"\f238"}.am-icon-subway:before{content:"\f239"}.am-icon-medium:before{content:"\f23a"}.am-icon-y-combinator:before,.am-icon-yc:before{content:"\f23b"}.am-icon-optin-monster:before{content:"\f23c"}.am-icon-opencart:before{content:"\f23d"}.am-icon-expeditedssl:before{content:"\f23e"}.am-icon-battery-4:before,.am-icon-battery-full:before{content:"\f240"}.am-icon-battery-3:before,.am-icon-battery-three-quarters:before{content:"\f241"}.am-icon-battery-2:before,.am-icon-battery-half:before{content:"\f242"}.am-icon-battery-1:before,.am-icon-battery-quarter:before{content:"\f243"}.am-icon-battery-0:before,.am-icon-battery-empty:before{content:"\f244"}.am-icon-mouse-pointer:before{content:"\f245"}.am-icon-i-cursor:before{content:"\f246"}.am-icon-object-group:before{content:"\f247"}.am-icon-object-ungroup:before{content:"\f248"}.am-icon-sticky-note:before{content:"\f249"}.am-icon-sticky-note-o:before{content:"\f24a"}.am-icon-cc-jcb:before{content:"\f24b"}.am-icon-cc-diners-club:before{content:"\f24c"}.am-icon-clone:before{content:"\f24d"}.am-icon-balance-scale:before{content:"\f24e"}.am-icon-hourglass-o:before{content:"\f250"}.am-icon-hourglass-1:before,.am-icon-hourglass-start:before{content:"\f251"}.am-icon-hourglass-2:before,.am-icon-hourglass-half:before{content:"\f252"}.am-icon-hourglass-3:before,.am-icon-hourglass-end:before{content:"\f253"}.am-icon-hourglass:before{content:"\f254"}.am-icon-hand-grab-o:before,.am-icon-hand-rock-o:before{content:"\f255"}.am-icon-hand-paper-o:before,.am-icon-hand-stop-o:before{content:"\f256"}.am-icon-hand-scissors-o:before{content:"\f257"}.am-icon-hand-lizard-o:before{content:"\f258"}.am-icon-hand-spock-o:before{content:"\f259"}.am-icon-hand-pointer-o:before{content:"\f25a"}.am-icon-hand-peace-o:before{content:"\f25b"}.am-icon-trademark:before{content:"\f25c"}.am-icon-registered:before{content:"\f25d"}.am-icon-creative-commons:before{content:"\f25e"}.am-icon-gg:before{content:"\f260"}.am-icon-gg-circle:before{content:"\f261"}.am-icon-tripadvisor:before{content:"\f262"}.am-icon-odnoklassniki:before{content:"\f263"}.am-icon-odnoklassniki-square:before{content:"\f264"}.am-icon-get-pocket:before{content:"\f265"}.am-icon-wikipedia-w:before{content:"\f266"}.am-icon-safari:before{content:"\f267"}.am-icon-chrome:before{content:"\f268"}.am-icon-firefox:before{content:"\f269"}.am-icon-opera:before{content:"\f26a"}.am-icon-internet-explorer:before{content:"\f26b"}.am-icon-television:before,.am-icon-tv:before{content:"\f26c"}.am-icon-contao:before{content:"\f26d"}.am-icon-500px:before{content:"\f26e"}.am-icon-amazon:before{content:"\f270"}.am-icon-calendar-plus-o:before{content:"\f271"}.am-icon-calendar-minus-o:before{content:"\f272"}.am-icon-calendar-times-o:before{content:"\f273"}.am-icon-calendar-check-o:before{content:"\f274"}.am-icon-industry:before{content:"\f275"}.am-icon-map-pin:before{content:"\f276"}.am-icon-map-signs:before{content:"\f277"}.am-icon-map-o:before{content:"\f278"}.am-icon-map:before{content:"\f279"}.am-icon-commenting:before{content:"\f27a"}.am-icon-commenting-o:before{content:"\f27b"}.am-icon-houzz:before{content:"\f27c"}.am-icon-vimeo:before{content:"\f27d"}.am-icon-black-tie:before{content:"\f27e"}.am-icon-fonticons:before{content:"\f280"}.am-icon-reddit-alien:before{content:"\f281"}.am-icon-edge:before{content:"\f282"}.am-icon-credit-card-alt:before{content:"\f283"}.am-icon-codiepie:before{content:"\f284"}.am-icon-modx:before{content:"\f285"}.am-icon-fort-awesome:before{content:"\f286"}.am-icon-usb:before{content:"\f287"}.am-icon-product-hunt:before{content:"\f288"}.am-icon-mixcloud:before{content:"\f289"}.am-icon-scribd:before{content:"\f28a"}.am-icon-pause-circle:before{content:"\f28b"}.am-icon-pause-circle-o:before{content:"\f28c"}.am-icon-stop-circle:before{content:"\f28d"}.am-icon-stop-circle-o:before{content:"\f28e"}.am-icon-shopping-bag:before{content:"\f290"}.am-icon-shopping-basket:before{content:"\f291"}.am-icon-hashtag:before{content:"\f292"}.am-icon-bluetooth:before{content:"\f293"}.am-icon-bluetooth-b:before{content:"\f294"}.am-icon-percent:before{content:"\f295"}.am-icon-gitlab:before{content:"\f296"}.am-icon-wpbeginner:before{content:"\f297"}.am-icon-wpforms:before{content:"\f298"}.am-icon-envira:before{content:"\f299"}.am-icon-universal-access:before{content:"\f29a"}.am-icon-wheelchair-alt:before{content:"\f29b"}.am-icon-question-circle-o:before{content:"\f29c"}.am-icon-blind:before{content:"\f29d"}.am-icon-audio-description:before{content:"\f29e"}.am-icon-volume-control-phone:before{content:"\f2a0"}.am-icon-braille:before{content:"\f2a1"}.am-icon-assistive-listening-systems:before{content:"\f2a2"}.am-icon-american-sign-language-interpreting:before,.am-icon-asl-interpreting:before{content:"\f2a3"}.am-icon-deaf:before,.am-icon-deafness:before,.am-icon-hard-of-hearing:before{content:"\f2a4"}.am-icon-glide:before{content:"\f2a5"}.am-icon-glide-g:before{content:"\f2a6"}.am-icon-sign-language:before,.am-icon-signing:before{content:"\f2a7"}.am-icon-low-vision:before{content:"\f2a8"}.am-icon-viadeo:before{content:"\f2a9"}.am-icon-viadeo-square:before{content:"\f2aa"}.am-icon-snapchat:before{content:"\f2ab"}.am-icon-snapchat-ghost:before{content:"\f2ac"}.am-icon-snapchat-square:before{content:"\f2ad"}.am-icon-pied-piper:before{content:"\f2ae"}.am-icon-first-order:before{content:"\f2b0"}.am-icon-yoast:before{content:"\f2b1"}.am-icon-themeisle:before{content:"\f2b2"}.am-icon-google-plus-circle:before,.am-icon-google-plus-official:before{content:"\f2b3"}.am-icon-fa:before,.am-icon-font-awesome:before{content:"\f2b4"}@-webkit-keyframes icon-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes icon-spin{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.am-icon-spin{-webkit-animation:icon-spin 2s infinite linear;animation:icon-spin 2s infinite linear}.am-icon-pulse{-webkit-animation:icon-spin 1s infinite steps(8);animation:icon-spin 1s infinite steps(8)}.am-icon-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.am-icon-ul>li{position:relative}.am-icon-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.am-input-group{position:relative;display:table;border-collapse:separate}.am-input-group .am-form-field{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.am-input-group .am-form-field,.am-input-group-btn,.am-input-group-label{display:table-cell}.am-input-group .am-form-field:not(:first-child):not(:last-child),.am-input-group-btn:not(:first-child):not(:last-child),.am-input-group-label:not(:first-child):not(:last-child){border-radius:0}.am-input-group-btn,.am-input-group-label{width:1%;white-space:nowrap;vertical-align:middle}.am-input-group-label{height:38px;padding:0 1em;font-size:1.6rem;font-weight:400;line-height:36px;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:0}.am-input-group-label input[type=checkbox],.am-input-group-label input[type=radio]{margin-top:0}.am-input-group .am-form-field:first-child,.am-input-group-btn:first-child>.am-btn,.am-input-group-btn:first-child>.am-btn-group>.am-btn,.am-input-group-btn:first-child>.am-dropdown-toggle,.am-input-group-btn:last-child>.am-btn-group:not(:last-child)>.am-btn,.am-input-group-btn:last-child>.am-btn:not(:last-child):not(.dropdown-toggle),.am-input-group-label:first-child{border-bottom-right-radius:0;border-top-right-radius:0}.am-input-group-label:first-child{border-right:0}.am-input-group .am-form-field:last-child,.am-input-group-btn:first-child>.am-btn-group:not(:first-child)>.am-btn,.am-input-group-btn:first-child>.am-btn:not(:first-child),.am-input-group-btn:last-child>.am-btn,.am-input-group-btn:last-child>.am-btn-group>.am-btn,.am-input-group-btn:last-child>.am-dropdown-toggle,.am-input-group-label:last-child{border-bottom-left-radius:0;border-top-left-radius:0}.am-input-group-label:last-child{border-left:0}.am-input-group-btn{position:relative;font-size:0;white-space:nowrap}.am-input-group-btn>.am-btn{position:relative;border-color:#ccc}.am-input-group-btn>.am-btn+.am-btn{margin-left:-1px}.am-input-group-btn>.am-btn:active,.am-input-group-btn>.am-btn:focus,.am-input-group-btn>.am-btn:hover{z-index:2}.am-input-group-btn:first-child>.am-btn,.am-input-group-btn:first-child>.am-btn-group{margin-right:-2px}.am-input-group-btn:last-child>.am-btn,.am-input-group-btn:last-child>.am-btn-group{margin-left:-1px}.am-input-group .am-form-field,.am-input-group-btn>.am-btn{height:38px;padding-bottom:auto}.am-input-group-lg>.am-form-field,.am-input-group-lg>.am-input-group-btn>.am-btn,.am-input-group-lg>.am-input-group-label{height:42px;font-size:1.8rem!important}.am-input-group-lg>.am-input-group-label{line-height:40px}.am-input-group-sm>.am-form-field,.am-input-group-sm>.am-input-group-btn>.am-btn,.am-input-group-sm>.am-input-group-label{height:33px;font-size:1.4rem!important}.am-input-group-sm>.am-input-group-label{line-height:31px}.am-input-group-primary .am-input-group-label{background:#0e90d2;color:#fff}.am-input-group-primary .am-input-group-btn>.am-btn,.am-input-group-primary .am-input-group-label,.am-input-group-primary.am-input-group .am-form-field{border-color:#0e90d2}.am-input-group-secondary .am-input-group-label{background:#3bb4f2;color:#fff}.am-input-group-secondary .am-input-group-btn>.am-btn,.am-input-group-secondary .am-input-group-label,.am-input-group-secondary.am-input-group .am-form-field{border-color:#3bb4f2}.am-input-group-success .am-input-group-label{background:#5eb95e;color:#fff}.am-input-group-success .am-input-group-btn>.am-btn,.am-input-group-success .am-input-group-label,.am-input-group-success.am-input-group .am-form-field{border-color:#5eb95e}.am-input-group-warning .am-input-group-label{background:#F37B1D;color:#fff}.am-input-group-warning .am-input-group-btn>.am-btn,.am-input-group-warning .am-input-group-label,.am-input-group-warning.am-input-group .am-form-field{border-color:#F37B1D}.am-input-group-danger .am-input-group-label{background:#dd514c;color:#fff}.am-input-group-danger .am-input-group-btn>.am-btn,.am-input-group-danger .am-input-group-label,.am-input-group-danger.am-input-group .am-form-field{border-color:#dd514c}.am-list{margin-bottom:1.6rem;padding-left:0}.am-list>li{position:relative;display:block;margin-bottom:-1px;background-color:#fff;border:1px solid #dedede;border-width:1px 0}.am-list>li>a{display:block;padding:1rem 0}.am-list>li>a.am-active,.am-list>li>a.am-active:focus,.am-list>li>a.am-active:hover{z-index:2;color:#fff;background-color:#0e90d2;border-color:#0e90d2}.am-list>li>a.am-active .am-list-item-heading,.am-list>li>a.am-active:focus .am-list-item-heading,.am-list>li>a.am-active:hover .am-list-item-heading{color:inherit}.am-list>li>a.am-active .am-list-item-text,.am-list>li>a.am-active:focus .am-list-item-text,.am-list>li>a.am-active:hover .am-list-item-text{color:#b2e2fa}.am-list>li>.am-badge{float:right}.am-list>li>.am-badge+.am-badge{margin-right:5px}.am-list-static>li{padding:.8rem .2rem}.am-list-static.am-list-border>li{padding:1rem}.am-list-border>li,.am-list-bordered>li{border-width:1px}.am-list-border>li:first-child,.am-list-border>li:first-child>a,.am-list-bordered>li:first-child,.am-list-bordered>li:first-child>a{border-top-right-radius:0;border-top-left-radius:0}.am-list-border>li:last-child,.am-list-border>li:last-child>a,.am-list-bordered>li:last-child,.am-list-bordered>li:last-child>a{margin-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.am-list-border>li>a,.am-list-bordered>li>a{padding:1rem}.am-list-border>li>a:focus,.am-list-border>li>a:hover,.am-list-bordered>li>a:focus,.am-list-bordered>li>a:hover{background-color:#f5f5f5}.am-list-striped>li:nth-of-type(even){background:#f5f5f5}.am-list-item-hd{margin-top:0}.am-list-item-text{line-height:1.4;font-size:1.3rem;color:#999;margin:0}.am-panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:0;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}.am-panel-hd{padding:.6rem 1.25rem;border-bottom:1px solid transparent;border-top-right-radius:0;border-top-left-radius:0}.am-panel-bd{padding:1.25rem}.am-panel-title{margin:0;font-size:100%;color:inherit}.am-panel-title>a{color:inherit}.am-panel-footer{padding:.6rem 1.25rem;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:0;border-bottom-left-radius:0}.am-panel-default{border-color:#ddd}.am-panel-default>.am-panel-hd{color:#444;background-color:#f5f5f5;border-color:#ddd}.am-panel-default>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#ddd}.am-panel-default>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#ddd}.am-panel-primary{border-color:#10a0ea}.am-panel-primary>.am-panel-hd{color:#fff;background-color:#0e90d2;border-color:#10a0ea}.am-panel-primary>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#10a0ea}.am-panel-primary>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#10a0ea}.am-panel-secondary{border-color:#caebfb}.am-panel-secondary>.am-panel-hd{color:#14a6ef;background-color:rgba(59,180,242,.15);border-color:#caebfb}.am-panel-secondary>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#caebfb}.am-panel-secondary>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#caebfb}.am-panel-success{border-color:#c9e7c9}.am-panel-success>.am-panel-hd{color:#5eb95e;background-color:rgba(94,185,94,.15);border-color:#c9e7c9}.am-panel-success>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#c9e7c9}.am-panel-success>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#c9e7c9}.am-panel-warning{border-color:#fbd0ae}.am-panel-warning>.am-panel-hd{color:#F37B1D;background-color:rgba(243,123,29,.15);border-color:#fbd0ae}.am-panel-warning>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#fbd0ae}.am-panel-warning>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#fbd0ae}.am-panel-danger{border-color:#f5cecd}.am-panel-danger>.am-panel-hd{color:#dd514c;background-color:rgba(221,81,76,.15);border-color:#f5cecd}.am-panel-danger>.am-panel-hd+.am-panel-collapse>.am-panel-bd{border-top-color:#f5cecd}.am-panel-danger>.am-panel-footer+.am-panel-collapse>.am-panel-bd{border-bottom-color:#f5cecd}.am-panel>.am-table{margin-bottom:0}.am-panel>.am-table:first-child{border-top-right-radius:0;border-top-left-radius:0}.am-panel>.am-table:first-child>tbody:first-child>tr:first-child td:first-child,.am-panel>.am-table:first-child>tbody:first-child>tr:first-child th:first-child,.am-panel>.am-table:first-child>thead:first-child>tr:first-child td:first-child,.am-panel>.am-table:first-child>thead:first-child>tr:first-child th:first-child{border-top-left-radius:0}.am-panel>.am-table:first-child>tbody:first-child>tr:first-child td:last-child,.am-panel>.am-table:first-child>tbody:first-child>tr:first-child th:last-child,.am-panel>.am-table:first-child>thead:first-child>tr:first-child td:last-child,.am-panel>.am-table:first-child>thead:first-child>tr:first-child th:last-child{border-top-right-radius:0}.am-panel>.am-table:last-child{border-bottom-right-radius:0;border-bottom-left-radius:0}.am-panel>.am-table:last-child>tbody:last-child>tr:last-child td:first-child,.am-panel>.am-table:last-child>tbody:last-child>tr:last-child th:first-child,.am-panel>.am-table:last-child>tfoot:last-child>tr:last-child td:first-child,.am-panel>.am-table:last-child>tfoot:last-child>tr:last-child th:first-child{border-bottom-left-radius:0}.am-panel>.am-table:last-child>tbody:last-child>tr:last-child td:last-child,.am-panel>.am-table:last-child>tbody:last-child>tr:last-child th:last-child,.am-panel>.am-table:last-child>tfoot:last-child>tr:last-child td:last-child,.am-panel>.am-table:last-child>tfoot:last-child>tr:last-child th:last-child{border-bottom-right-radius:0}.am-panel>.am-panel-bd+.am-table{border-top:1px solid #ddd}.am-panel>.am-table>tbody:first-child>tr:first-child td,.am-panel>.am-table>tbody:first-child>tr:first-child th{border-top:0}.am-panel>.am-table-bd{border:0}.am-panel>.am-table-bd>tbody>tr>td:first-child,.am-panel>.am-table-bd>tbody>tr>th:first-child,.am-panel>.am-table-bd>tfoot>tr>td:first-child,.am-panel>.am-table-bd>tfoot>tr>th:first-child,.am-panel>.am-table-bd>thead>tr>td:first-child,.am-panel>.am-table-bd>thead>tr>th:first-child{border-left:0}.am-panel>.am-table-bd>tbody>tr>td:last-child,.am-panel>.am-table-bd>tbody>tr>th:last-child,.am-panel>.am-table-bd>tfoot>tr>td:last-child,.am-panel>.am-table-bd>tfoot>tr>th:last-child,.am-panel>.am-table-bd>thead>tr>td:last-child,.am-panel>.am-table-bd>thead>tr>th:last-child{border-right:0}.am-panel>.am-table-bd>tbody>tr:first-child>td,.am-panel>.am-table-bd>tbody>tr:first-child>th,.am-panel>.am-table-bd>thead>tr:first-child>td,.am-panel>.am-table-bd>thead>tr:first-child>th{border-bottom:0}.am-panel>.am-table-bd>tbody>tr:last-child>td,.am-panel>.am-table-bd>tbody>tr:last-child>th,.am-panel>.am-table-bd>tfoot>tr:last-child>td,.am-panel>.am-table-bd>tfoot>tr:last-child>th{border-bottom:0}.am-panel>.am-list{margin:0}.am-panel>.am-list>li>a{padding-left:1rem;padding-right:1rem}.am-panel>.am-list-static li{padding-left:1rem;padding-right:1rem}.am-panel-group{margin-bottom:2rem}.am-panel-group .am-panel{margin-bottom:0;border-radius:0}.am-panel-group .am-panel+.am-panel{margin-top:6px}.am-panel-group .am-panel-hd{border-bottom:0}.am-panel-group .am-panel-hd+.am-panel-collapse .am-panel-bd{border-top:1px solid #ddd}.am-panel-group .am-panel-footer{border-top:0}.am-panel-group .am-panel-footer+.am-panel-collapse .am-panel-bd{border-bottom:1px solid #ddd}@-webkit-keyframes progress-bar-stripes{from{background-position:36px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:36px 0}to{background-position:0 0}}.am-progress{overflow:hidden;height:2rem;margin-bottom:2rem;background-color:#f5f5f5;border-radius:0;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.am-progress-bar{float:left;width:0;height:100%;font-size:1.2rem;line-height:2rem;color:#fff;text-align:center;background-color:#0e90d2;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;transition:width .6s ease}.am-progress-striped .am-progress-bar{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:36px 36px;background-size:36px 36px}.am-progress.am-active .am-progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.am-progress-bar[aria-valuenow="1"],.am-progress-bar[aria-valuenow="2"]{min-width:30px}.am-progress-bar[aria-valuenow="0"]{color:#999;min-width:30px;background:0 0;-webkit-box-shadow:none;box-shadow:none}.am-progress-bar-secondary{background-color:#3bb4f2}.am-progress-striped .am-progress-bar-secondary{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.am-progress-bar-success{background-color:#5eb95e}.am-progress-striped .am-progress-bar-success{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.am-progress-bar-warning{background-color:#F37B1D}.am-progress-striped .am-progress-bar-warning{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.am-progress-bar-danger{background-color:#dd514c}.am-progress-striped .am-progress-bar-danger{background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(.25,rgba(255,255,255,.15)),color-stop(.25,transparent),color-stop(.5,transparent),color-stop(.5,rgba(255,255,255,.15)),color-stop(.75,rgba(255,255,255,.15)),color-stop(.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.am-progress-xs{height:.6rem}.am-progress-sm{height:1.2rem}.am-thumbnail{display:block;padding:2px;margin-bottom:2rem;background-color:#fff;border:1px solid #ddd;border-radius:0;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.am-thumbnail a>img,.am-thumbnail>img{margin-left:auto;margin-right:auto;display:block}.am-thumbnail a.am-thumbnail.active,.am-thumbnail a.am-thumbnail:focus,.am-thumbnail a.am-thumbnail:hover{border-color:#0e90d2;background-color:#fff}.am-thumbnail a>img,.am-thumbnail>img,img.am-thumbnail{max-width:100%;height:auto}.am-thumbnail-caption{margin:0;padding:.8rem;color:#333;font-weight:400}.am-thumbnail-caption :last-child{margin-bottom:0}.am-thumbnails{margin-left:-.5rem;margin-right:-.5rem}.am-thumbnails>li{padding:0 .5rem 1rem .5rem}.am-scrollable-horizontal{width:100%;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:-ms-autohiding-scrollbar;-webkit-overflow-scrolling:touch}.am-scrollable-vertical{height:240px;overflow-y:scroll;-webkit-overflow-scrolling:touch;resize:vertical}.am-square{border-radius:0}.am-radius{border-radius:2px}.am-round{border-radius:1000px}.am-circle{border-radius:50%}.am-cf:after,.am-cf:before{content:" ";display:table}.am-cf:after{clear:both}.am-fl{float:left}.am-fr{float:right}.am-nbfc{overflow:hidden}.am-center{display:block;margin-left:auto;margin-right:auto}.am-block{display:block!important}.am-inline{display:inline!important}.am-inline-block{display:inline-block!important}.am-hide{display:none!important;visibility:hidden!important}.am-vertical-align{font-size:0}.am-vertical-align:before{content:'';display:inline-block;height:100%;vertical-align:middle}.am-vertical-align-bottom,.am-vertical-align-middle{display:inline-block;font-size:1.6rem;max-width:100%}.am-vertical-align-middle{vertical-align:middle}.am-vertical-align-bottom{vertical-align:bottom}.am-responsive-width{-webkit-box-sizing:border-box;box-sizing:border-box;max-width:100%;height:auto}.am-margin{margin:1.6rem}.am-margin-0{margin:0!important}.am-margin-xs{margin:.5rem}.am-margin-sm{margin:1rem}.am-margin-lg{margin:2.4rem}.am-margin-xl{margin:3.2rem}.am-margin-horizontal{margin-left:1.6rem;margin-right:1.6rem}.am-margin-horizontal-0{margin-left:0!important;margin-right:0!important}.am-margin-horizontal-xs{margin-left:.5rem;margin-right:.5rem}.am-margin-horizontal-sm{margin-left:1rem;margin-right:1rem}.am-margin-horizontal-lg{margin-left:2.4rem;margin-right:2.4rem}.am-margin-horizontal-xl{margin-left:3.2rem;margin-right:3.2rem}.am-margin-vertical{margin-top:1.6rem;margin-bottom:1.6rem}.am-margin-vertical-0{margin-top:0!important;margin-bottom:0!important}.am-margin-vertical-xs{margin-top:.5rem;margin-bottom:.5rem}.am-margin-vertical-sm{margin-top:1rem;margin-bottom:1rem}.am-margin-vertical-lg{margin-top:2.4rem;margin-bottom:2.4rem}.am-margin-vertical-xl{margin-top:3.2rem;margin-bottom:3.2rem}.am-margin-top{margin-top:1.6rem}.am-margin-top-0{margin-top:0!important}.am-margin-top-xs{margin-top:.5rem}.am-margin-top-sm{margin-top:1rem}.am-margin-top-lg{margin-top:2.4rem}.am-margin-top-xl{margin-top:3.2rem}.am-margin-bottom{margin-bottom:1.6rem}.am-margin-bottom-0{margin-bottom:0!important}.am-margin-bottom-xs{margin-bottom:.5rem}.am-margin-bottom-sm{margin-bottom:1rem}.am-margin-bottom-lg{margin-bottom:2.4rem}.am-margin-bottom-xl{margin-bottom:3.2rem}.am-margin-left{margin-left:1.6rem}.am-margin-left-0{margin-left:0!important}.am-margin-left-xs{margin-left:.5rem}.am-margin-left-sm{margin-left:1rem}.am-margin-left-lg{margin-left:2.4rem}.am-margin-left-xl{margin-left:3.2rem}.am-margin-right{margin-right:1.6rem}.am-margin-right-0{margin-right:0!important}.am-margin-right-xs{margin-right:.5rem}.am-margin-right-sm{margin-right:1rem}.am-margin-right-lg{margin-right:2.4rem}.am-margin-right-xl{margin-right:3.2rem}.am-padding{padding:1.6rem}.am-padding-0{padding:0!important}.am-padding-xs{padding:.5rem}.am-padding-sm{padding:1rem}.am-padding-lg{padding:2.4rem}.am-padding-xl{padding:3.2rem}.am-padding-horizontal{padding-left:1.6rem;padding-right:1.6rem}.am-padding-horizontal-0{padding-left:0!important;padding-right:0!important}.am-padding-horizontal-xs{padding-left:.5rem;padding-right:.5rem}.am-padding-horizontal-sm{padding-left:1rem;padding-right:1rem}.am-padding-horizontal-lg{padding-left:2.4rem;padding-right:2.4rem}.am-padding-horizontal-xl{padding-left:3.2rem;padding-right:3.2rem}.am-padding-vertical{padding-top:1.6rem;padding-bottom:1.6rem}.am-padding-vertical-0{padding-top:0!important;padding-bottom:0!important}.am-padding-vertical-xs{padding-top:.5rem;padding-bottom:.5rem}.am-padding-vertical-sm{padding-top:1rem;padding-bottom:1rem}.am-padding-vertical-lg{padding-top:2.4rem;padding-bottom:2.4rem}.am-padding-vertical-xl{padding-top:3.2rem;padding-bottom:3.2rem}.am-padding-top{padding-top:1.6rem}.am-padding-top-0{padding-top:0!important}.am-padding-top-xs{padding-top:.5rem}.am-padding-top-sm{padding-top:1rem}.am-padding-top-lg{padding-top:2.4rem}.am-padding-top-xl{padding-top:3.2rem}.am-padding-bottom{padding-bottom:1.6rem}.am-padding-bottom-0{padding-bottom:0!important}.am-padding-bottom-xs{padding-bottom:.5rem}.am-padding-bottom-sm{padding-bottom:1rem}.am-padding-bottom-lg{padding-bottom:2.4rem}.am-padding-bottom-xl{padding-bottom:3.2rem}.am-padding-left{padding-left:1.6rem}.am-padding-left-0{padding-left:0!important}.am-padding-left-xs{padding-left:.5rem}.am-padding-left-sm{padding-left:1rem}.am-padding-left-lg{padding-left:2.4rem}.am-padding-left-xl{padding-left:3.2rem}.am-padding-right{padding-right:1.6rem}.am-padding-right-0{padding-right:0!important}.am-padding-right-xs{padding-right:.5rem}.am-padding-right-sm{padding-right:1rem}.am-padding-right-lg{padding-right:2.4rem}.am-padding-right-xl{padding-right:3.2rem}@media only screen{.am-hide-lg,.am-hide-lg-only,.am-hide-lg-up,.am-hide-md,.am-hide-md-only,.am-hide-md-up,.am-show-lg-down,.am-show-md-down,.am-show-sm,.am-show-sm-down,.am-show-sm-only,.am-show-sm-up{display:inherit!important}.am-hide-lg-down,.am-hide-md-down,.am-hide-sm,.am-hide-sm-down,.am-hide-sm-only,.am-hide-sm-up,.am-show-lg,.am-show-lg-only,.am-show-lg-up,.am-show-md,.am-show-md-only,.am-show-md-up{display:none!important}table.am-hide-lg,table.am-hide-lg-only,table.am-hide-lg-up,table.am-hide-md,table.am-hide-md-only,table.am-hide-md-up,table.am-show-lg-down,table.am-show-md-down,table.am-show-sm,table.am-show-sm-down,table.am-show-sm-only,table.am-show-sm-up{display:table!important}thead.am-hide-lg,thead.am-hide-lg-only,thead.am-hide-lg-up,thead.am-hide-md,thead.am-hide-md-only,thead.am-hide-md-up,thead.am-show-lg-down,thead.am-show-md-down,thead.am-show-sm,thead.am-show-sm-down,thead.am-show-sm-only,thead.am-show-sm-up{display:table-header-group!important}tbody.am-hide-lg,tbody.am-hide-lg-only,tbody.am-hide-lg-up,tbody.am-hide-md,tbody.am-hide-md-only,tbody.am-hide-md-up,tbody.am-show-lg-down,tbody.am-show-md-down,tbody.am-show-sm,tbody.am-show-sm-down,tbody.am-show-sm-only,tbody.am-show-sm-up{display:table-row-group!important}tr.am-hide-lg,tr.am-hide-lg-only,tr.am-hide-lg-up,tr.am-hide-md,tr.am-hide-md-only,tr.am-hide-md-up,tr.am-show-lg-down,tr.am-show-md-down,tr.am-show-sm,tr.am-show-sm-down,tr.am-show-sm-only,tr.am-show-sm-up{display:table-row!important}td.am-hide-lg,td.am-hide-lg-only,td.am-hide-lg-up,td.am-hide-md,td.am-hide-md-only,td.am-hide-md-up,td.am-show-lg-down,td.am-show-md-down,td.am-show-sm,td.am-show-sm-down,td.am-show-sm-only,td.am-show-sm-up,th.am-hide-lg,th.am-hide-lg-only,th.am-hide-lg-up,th.am-hide-md,th.am-hide-md-only,th.am-hide-md-up,th.am-show-lg-down,th.am-show-md-down,th.am-show-sm,th.am-show-sm-down,th.am-show-sm-only,th.am-show-sm-up{display:table-cell!important}}@media only screen and (min-width:641px){.am-hide-lg,.am-hide-lg-only,.am-hide-lg-up,.am-hide-sm,.am-hide-sm-down,.am-hide-sm-only,.am-show-lg-down,.am-show-md,.am-show-md-down,.am-show-md-only,.am-show-md-up,.am-show-sm-up{display:inherit!important}.am-hide-lg-down,.am-hide-md,.am-hide-md-down,.am-hide-md-only,.am-hide-md-up,.am-hide-sm-up,.am-show-lg,.am-show-lg-only,.am-show-lg-up,.am-show-sm,.am-show-sm-down,.am-show-sm-only{display:none!important}table.am-hide-lg,table.am-hide-lg-only,table.am-hide-lg-up,table.am-hide-sm,table.am-hide-sm-down,table.am-hide-sm-only,table.am-show-lg-down,table.am-show-md,table.am-show-md-down,table.am-show-md-only,table.am-show-md-up,table.am-show-sm-up{display:table!important}thead.am-hide-lg,thead.am-hide-lg-only,thead.am-hide-lg-up,thead.am-hide-sm,thead.am-hide-sm-down,thead.am-hide-sm-only,thead.am-show-lg-down,thead.am-show-md,thead.am-show-md-down,thead.am-show-md-only,thead.am-show-md-up,thead.am-show-sm-up{display:table-header-group!important}tbody.am-hide-lg,tbody.am-hide-lg-only,tbody.am-hide-lg-up,tbody.am-hide-sm,tbody.am-hide-sm-down,tbody.am-hide-sm-only,tbody.am-show-lg-down,tbody.am-show-md,tbody.am-show-md-down,tbody.am-show-md-only,tbody.am-show-md-up,tbody.am-show-sm-up{display:table-row-group!important}tr.am-hide-lg,tr.am-hide-lg-only,tr.am-hide-lg-up,tr.am-hide-sm,tr.am-hide-sm-down,tr.am-hide-sm-only,tr.am-show-lg-down,tr.am-show-md,tr.am-show-md-down,tr.am-show-md-only,tr.am-show-md-up,tr.am-show-sm-up{display:table-row!important}td.am-hide-lg,td.am-hide-lg-only,td.am-hide-lg-up,td.am-hide-sm,td.am-hide-sm-down,td.am-hide-sm-only,td.am-show-lg-down,td.am-show-md,td.am-show-md-down,td.am-show-md-only,td.am-show-md-up,td.am-show-sm-up,th.am-hide-lg,th.am-hide-lg-only,th.am-hide-lg-up,th.am-hide-sm,th.am-hide-sm-down,th.am-hide-sm-only,th.am-show-lg-down,th.am-show-md,th.am-show-md-down,th.am-show-md-only,th.am-show-md-up,th.am-show-sm-up{display:table-cell!important}}@media only screen and (min-width:1025px){.am-hide-md,.am-hide-md-down,.am-hide-md-only,.am-hide-sm,.am-hide-sm-down,.am-hide-sm-only,.am-show-lg,.am-show-lg-down,.am-show-lg-only,.am-show-lg-up,.am-show-md-up,.am-show-sm-up{display:inherit!important}.am-hide-lg,.am-hide-lg-down,.am-hide-lg-only,.am-hide-lg-up,.am-hide-md-up,.am-hide-sm-up,.am-show-md,.am-show-md-down,.am-show-md-only,.am-show-sm,.am-show-sm-down,.am-show-sm-only{display:none!important}table.am-hide-md,table.am-hide-md-down,table.am-hide-md-only,table.am-hide-sm,table.am-hide-sm-down,table.am-hide-sm-only,table.am-show-lg,table.am-show-lg-down,table.am-show-lg-only,table.am-show-lg-up,table.am-show-md-up,table.am-show-sm-up{display:table!important}thead.am-hide-md,thead.am-hide-md-down,thead.am-hide-md-only,thead.am-hide-sm,thead.am-hide-sm-down,thead.am-hide-sm-only,thead.am-show-lg,thead.am-show-lg-down,thead.am-show-lg-only,thead.am-show-lg-up,thead.am-show-md-up,thead.am-show-sm-up{display:table-header-group!important}tbody.am-hide-md,tbody.am-hide-md-down,tbody.am-hide-md-only,tbody.am-hide-sm,tbody.am-hide-sm-down,tbody.am-hide-sm-only,tbody.am-show-lg,tbody.am-show-lg-down,tbody.am-show-lg-only,tbody.am-show-lg-up,tbody.am-show-md-up,tbody.am-show-sm-up{display:table-row-group!important}tr.am-hide-md,tr.am-hide-md-down,tr.am-hide-md-only,tr.am-hide-sm,tr.am-hide-sm-down,tr.am-hide-sm-only,tr.am-show-lg,tr.am-show-lg-down,tr.am-show-lg-only,tr.am-show-lg-up,tr.am-show-md-up,tr.am-show-sm-up{display:table-row!important}td.am-hide-md,td.am-hide-md-down,td.am-hide-md-only,td.am-hide-sm,td.am-hide-sm-down,td.am-hide-sm-only,td.am-show-lg,td.am-show-lg-down,td.am-show-lg-only,td.am-show-lg-up,td.am-show-md-up,td.am-show-sm-up,th.am-hide-md,th.am-hide-md-down,th.am-hide-md-only,th.am-hide-sm,th.am-hide-sm-down,th.am-hide-sm-only,th.am-show-lg,th.am-show-lg-down,th.am-show-lg-only,th.am-show-lg-up,th.am-show-md-up,th.am-show-sm-up{display:table-cell!important}}@media only screen and (orientation:landscape){.am-hide-portrait,.am-show-landscape{display:inherit!important}.am-hide-landscape,.am-show-portrait{display:none!important}}@media only screen and (orientation:portrait){.am-hide-landscape,.am-show-portrait{display:inherit!important}.am-hide-portrait,.am-show-landscape{display:none!important}}.am-sans-serif{font-family:"Segoe UI","Lucida Grande",Helvetica,Arial,"Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif}.am-serif{font-family:Georgia,"Times New Roman",Times,SimSun,FontAwesome,serif}.am-kai{font-family:Georgia,"Times New Roman",Times,Kai,"Kaiti SC",KaiTi,BiauKai,FontAwesome,serif}.am-monospace{font-family:Monaco,Menlo,Consolas,"Courier New",FontAwesome,monospace}.am-text-primary{color:#0e90d2}.am-text-secondary{color:#3bb4f2}.am-text-success{color:#5eb95e}.am-text-warning{color:#F37B1D}.am-text-danger{color:#dd514c}.am-link-muted{color:#666}.am-link-muted a{color:#666}.am-link-muted a:hover,.am-link-muted:hover{color:#555}.am-text-default{font-size:1.6rem}.am-text-xs{font-size:1.2rem}.am-text-sm{font-size:1.4rem}.am-text-lg{font-size:1.8rem}.am-text-xl{font-size:2.4rem}.am-text-xxl{font-size:3.2rem}.am-text-xxxl{font-size:4.2rem}.am-ellipsis,.am-text-truncate{word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-text-break{word-wrap:break-word;-webkit-hyphens:auto;-ms-hyphens:auto;-moz-hyphens:auto;hyphens:auto}.am-text-nowrap{white-space:nowrap}[class*=am-align-]{margin-bottom:1rem}.am-align-left{margin-right:1rem;float:left}.am-align-right{margin-left:1rem;float:right}.am-sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0}.am-text-ir{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}@media only screen{.am-text-left{text-align:left!important}.am-text-right{text-align:right!important}.am-text-center{text-align:center!important}.am-text-justify{text-align:justify!important}}@media only screen and (max-width:640px){.am-sm-only-text-left{text-align:left!important}.am-sm-only-text-right{text-align:right!important}.am-sm-only-text-center{text-align:center!important}.am-sm-only-text-justify{text-align:justify!important}}@media only screen and (min-width:641px) and (max-width:1024px){.am-md-only-text-left{text-align:left!important}.am-md-only-text-right{text-align:right!important}.am-md-only-text-center{text-align:center!important}.am-md-only-text-justify{text-align:justify!important}}@media only screen and (min-width:641px){.am-md-text-left{text-align:left!important}.am-md-text-right{text-align:right!important}.am-md-text-center{text-align:center!important}.am-md-text-justify{text-align:justify!important}}@media only screen and (min-width:1025px){.am-lg-text-left{text-align:left!important}.am-lg-text-right{text-align:right!important}.am-lg-text-center{text-align:center!important}.am-lg-text-justify{text-align:justify!important}}.am-text-top{vertical-align:top!important}.am-text-middle{vertical-align:middle!important}.am-text-bottom{vertical-align:bottom!important}.am-angle{position:absolute}.am-angle:after,.am-angle:before{position:absolute;display:block;content:"";width:0;height:0;border:8px dashed transparent;z-index:1}.am-angle-up{top:0}.am-angle-up:after,.am-angle-up:before{border-bottom-style:solid;border-width:0 8px 8px}.am-angle-up:before{border-bottom-color:#ddd;bottom:0}.am-angle-up:after{border-bottom-color:#fff;bottom:-1px}.am-angle-down{bottom:-9px}.am-angle-down:after,.am-angle-down:before{border-top-style:solid;border-width:8px 8px 0}.am-angle-down:before{border-top-color:#ddd;bottom:0}.am-angle-down:after{border-top-color:#fff;bottom:1px}.am-angle-left{left:-9px}.am-angle-left:after,.am-angle-left:before{border-right-style:solid;border-width:8px 8px 8px 0}.am-angle-left:before{border-right-color:#ddd;left:0}.am-angle-left:after{border-right-color:#fff;left:1px}.am-angle-right{right:0}.am-angle-right:after,.am-angle-right:before{border-left-style:solid;border-width:8px 0 8px 8px}.am-angle-right:before{border-left-color:#ddd;left:0}.am-angle-right:after{border-left-color:#fff;left:-1px}.am-alert{margin-bottom:1em;padding:.625em;background:#0e90d2;color:#fff;border:1px solid #0c7cb5;border-radius:0}.am-alert a{color:#fff}.am-alert h1,.am-alert h2,.am-alert h3,.am-alert h4,.am-alert h5,.am-alert h6{color:inherit}.am-alert .am-close{opacity:.4}.am-alert .am-close:hover{opacity:.6}*+.am-alert{margin-top:1em}.am-alert>:last-child{margin-bottom:0}.am-form-group .am-alert{margin:5px 0 0;padding:.25em .625em;font-size:1.3rem}.am-alert>.am-close:first-child{float:right;height:auto;margin:-3px -5px auto auto}.am-alert>.am-close:first-child+*{margin-top:0}.am-alert-secondary{background-color:#eee;border-color:#dfdfdf;color:#555}.am-alert-success{background-color:#5eb95e;border-color:#4bad4b;color:#fff}.am-alert-warning{background-color:#F37B1D;border-color:#e56c0c;color:#fff}.am-alert-danger{background-color:#dd514c;border-color:#d83832;color:#fff}.am-dropdown{position:relative;display:inline-block}.am-dropdown-toggle:focus{outline:0}.am-dropdown-content{position:absolute;top:100%;left:0;z-index:1020;display:none;float:left;min-width:160px;padding:15px;margin:9px 0 0;text-align:left;line-height:1.6;background-color:#fff;border:1px solid #ddd;border-radius:0;-webkit-background-clip:padding-box;background-clip:padding-box;-webkit-animation-duration:.15s;animation-duration:.15s}.am-dropdown-content:after,.am-dropdown-content:before{position:absolute;display:block;content:"";width:0;height:0;border:8px dashed transparent;z-index:1}.am-dropdown-content:after,.am-dropdown-content:before{border-bottom-style:solid;border-width:0 8px 8px}.am-dropdown-content:before{border-bottom-color:#ddd;bottom:0}.am-dropdown-content:after{border-bottom-color:#fff;bottom:-1px}.am-dropdown-content:after,.am-dropdown-content:before{left:10px;top:-8px;pointer-events:none}.am-dropdown-content:after{top:-7px}.am-active>.am-dropdown-content{display:block}.am-dropdown-content :first-child{margin-top:0}.am-dropdown-up .am-dropdown-content{top:auto;bottom:100%;margin:0 0 9px}.am-dropdown-up .am-dropdown-content:after,.am-dropdown-up .am-dropdown-content:before{border-bottom:none;border-top:8px solid #ddd;top:auto;bottom:-8px}.am-dropdown-up .am-dropdown-content:after{bottom:-7px;border-top-color:#fff}.am-dropdown-flip .am-dropdown-content{left:auto;right:0}.am-dropdown-flip .am-dropdown-content:after,.am-dropdown-flip .am-dropdown-content:before{left:auto;right:10px}ul.am-dropdown-content{list-style:none;padding:5px 0}ul.am-dropdown-content.am-fr{right:0;left:auto}ul.am-dropdown-content .am-divider{height:1px;margin:0rem 0;overflow:hidden;background-color:#e5e5e5}ul.am-dropdown-content>li>a{display:block;padding:6px 20px;clear:both;font-weight:400;color:#333;white-space:nowrap}ul.am-dropdown-content>li>a:focus,ul.am-dropdown-content>li>a:hover{text-decoration:none;color:#262626;background-color:#f5f5f5}ul.am-dropdown-content>.am-active>a,ul.am-dropdown-content>.am-active>a:focus,ul.am-dropdown-content>.am-active>a:hover{color:#fff;text-decoration:none;outline:0;background-color:#0e90d2}ul.am-dropdown-content>.am-disabled>a,ul.am-dropdown-content>.am-disabled>a:focus,ul.am-dropdown-content>.am-disabled>a:hover{color:#999}ul.am-dropdown-content>.am-disabled>a:focus,ul.am-dropdown-content>.am-disabled>a:hover{text-decoration:none;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);cursor:not-allowed}.am-dropdown-header{display:block;padding:6px 20px;font-size:1.2rem;color:#999}.am-fr>.am-dropdown-content{right:0;left:auto}.am-fr>.am-dropdown-content:before{right:10px;left:auto}.am-dropdown-animation{-webkit-animation:am-dropdown-animation .15s ease-out;animation:am-dropdown-animation .15s ease-out}@-webkit-keyframes am-dropdown-animation{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}100%{opacity:0;-webkit-transform:translateY(-10px);transform:translateY(-10px)}}@keyframes am-dropdown-animation{0%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}100%{opacity:0;-webkit-transform:translateY(-10px);transform:translateY(-10px)}}.am-slider a:focus,.am-slider a:hover{outline:0}.am-control-nav,.am-direction-nav,.am-slides{margin:0;padding:0;list-style:none}.am-slider{margin:0;padding:0}.am-slider .am-slides:after,.am-slider .am-slides:before{content:" ";display:table}.am-slider .am-slides:after{clear:both}.am-slider .am-slides>li{display:none;-webkit-backface-visibility:hidden;position:relative}.no-js .am-slider .am-slides>li:first-child{display:block}.am-slider .am-slides img{width:100%;display:block}.am-pauseplay span{text-transform:capitalize}.am-slider{position:relative}.am-viewport{-webkit-transition:all 1s ease;transition:all 1s ease}.am-slider-carousel li{margin-right:5px}.am-control-nav{position:absolute}.am-control-nav li{display:inline-block}.am-control-thumbs{position:static;overflow:hidden}.am-control-thumbs img{-webkit-transition:all 1s ease;transition:all 1s ease}.am-slider-slide .am-slides>li{display:none;position:relative}@media all and (transform-3d),(-webkit-transform-3d){.am-slider-slide .am-slides>li{-webkit-transition:-webkit-transform .6s ease-in-out;transition:-webkit-transform .6s ease-in-out;transition:transform .6s ease-in-out;transition:transform .6s ease-in-out,-webkit-transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;perspective:1000px}.am-slider-slide .am-slides>li.active.right,.am-slider-slide .am-slides>li.next{-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0);left:0}.am-slider-slide .am-slides>li.active.left,.am-slider-slide .am-slides>li.prev{-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0);left:0}.am-slider-slide .am-slides>li.active,.am-slider-slide .am-slides>li.next.left,.am-slider-slide .am-slides>li.prev.right{-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);left:0}}.am-slider-slide .am-slides>.active,.am-slider-slide .am-slides>.next,.am-slider-slide .am-slides>.prev{display:block}.am-slider-slide .am-slides>.active{left:0}.am-slider-slide .am-slides>.next,.am-slider-slide .am-slides>.prev{position:absolute;top:0;width:100%}.am-slider-slide .am-slides>.next{left:100%}.am-slider-slide .am-slides>.prev{left:-100%}.am-slider-slide .am-slides>.next.left,.am-slider-slide .am-slides>.prev.right{left:0}.am-slider-slide .am-slides>.active.left{left:-100%}.am-slider-slide .am-slides>.active.right{left:100%}.am-slider-default{margin:0 0 20px;background-color:#fff;border-radius:2px;-webkit-box-shadow:0 0 2px rgba(0,0,0,.15);box-shadow:0 0 2px rgba(0,0,0,.15)}.am-slider-default .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-default .am-viewport{max-height:300px}.am-slider-default .carousel li{margin-right:5px}.am-slider-default .am-direction-nav a{position:absolute;top:50%;z-index:10;display:block;width:36px;height:36px;margin:-18px 0 0;overflow:hidden;opacity:.45;cursor:pointer;color:rgba(0,0,0,.65);-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-default .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);width:100%;color:#333;content:"\f137";font-size:24px!important;text-align:center;line-height:36px!important;height:36px}.am-slider-default .am-direction-nav a.am-next:before{content:"\f138"}.am-slider-default .am-direction-nav .am-prev{left:10px}.am-slider-default .am-direction-nav .am-next{right:10px;text-align:right}.am-slider-default .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-default:hover .am-prev{opacity:.7;left:10px}.am-slider-default:hover .am-prev:hover{opacity:1}.am-slider-default:hover .am-next{opacity:.7;right:10px}.am-slider-default:hover .am-next:hover{opacity:1}.am-slider-default .am-pauseplay a{display:block;width:20px;height:20px;position:absolute;bottom:5px;left:10px;opacity:.8;z-index:10;overflow:hidden;cursor:pointer;color:#000}.am-slider-default .am-pauseplay a::before{font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);font-size:20px;display:inline-block;content:"\f04c"}.am-slider-default .am-pauseplay a:hover{opacity:1}.am-slider-default .am-pauseplay a.am-play::before{content:"\f04b"}.am-slider-default .am-slider-desc{background-color:rgba(0,0,0,.7);position:absolute;bottom:0;padding:10px;width:100%;color:#fff}.am-slider-default .am-control-nav{width:100%;position:absolute;bottom:-15px;text-align:center}.am-slider-default .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-default .am-control-nav li a{width:8px;height:8px;display:block;background-color:#666;background-color:rgba(0,0,0,.5);line-height:0;font-size:0;cursor:pointer;text-indent:-9999px;border-radius:20px;-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,.3);box-shadow:inset 0 0 3px rgba(0,0,0,.3)}.am-slider-default .am-control-nav li a:hover{background-color:#333;background-color:rgba(0,0,0,.7)}.am-slider-default .am-control-nav li a.am-active{background-color:#000;background-color:#0e90d2;cursor:default}.am-slider-default .am-control-thumbs{margin:5px 0 0;position:static;overflow:hidden}.am-slider-default .am-control-thumbs li{width:25%;float:left;margin:0}.am-slider-default .am-control-thumbs img{width:100%;height:auto;display:block;opacity:.7;cursor:pointer}.am-slider-default .am-control-thumbs img:hover{opacity:1}.am-slider-default .am-control-thumbs .am-active{opacity:1;cursor:default}.am-slider-default .am-control-thumbs i{position:absolute}.am-modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1110;display:none;opacity:0;outline:0;text-align:center;-webkit-transform:scale(1.185);-ms-transform:scale(1.185);transform:scale(1.185);-webkit-transition-property:opacity,-webkit-transform;transition-property:opacity,-webkit-transform;transition-property:transform,opacity;transition-property:transform,opacity,-webkit-transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;perspective:1000px}.am-modal:focus{outline:0}.am-modal.am-modal-active{opacity:1;-webkit-transition-duration:.3s;transition-duration:.3s;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);overflow-x:hidden;overflow-y:auto}.am-modal.am-modal-out{opacity:0;z-index:1109;-webkit-transition-duration:.3s;transition-duration:.3s;-webkit-transform:scale(.815);-ms-transform:scale(.815);transform:scale(.815)}.am-modal:before{content:"\200B";display:inline-block;height:100%;vertical-align:middle}.am-modal-dialog{position:relative;display:inline-block;vertical-align:middle;margin-left:auto;margin-right:auto;width:270px;max-width:100%;border-radius:0;background:#f8f8f8}@media only screen and (min-width:641px){.am-modal-dialog{width:540px}}.am-modal-hd{padding:15px 10px 5px 10px;font-size:1.8rem;font-weight:500}.am-modal-hd+.am-modal-bd{padding-top:0}.am-modal-hd .am-close{position:absolute;top:4px;right:4px}.am-modal-bd{padding:15px 10px;text-align:center;border-bottom:1px solid #dedede;border-radius:2px 2px 0 0}.am-modal-bd+.am-modal-bd{margin-top:5px}.am-modal-prompt-input{display:block;margin:5px auto 0 auto;border-radius:0;padding:5px;line-height:1.8rem;width:80%;border:1px solid #dedede;-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none}.am-modal-prompt-input:focus{outline:0;border-color:#d6d6d6}.am-modal-footer{height:44px;overflow:hidden;display:table;width:100%;border-collapse:collapse}.am-modal-btn{display:table-cell!important;padding:0 5px;height:44px;-webkit-box-sizing:border-box!important;box-sizing:border-box!important;font-size:1.6rem;line-height:44px;text-align:center;color:#0e90d2;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;cursor:pointer;border-right:1px solid #dedede}.am-modal-btn:first-child{border-radius:0}.am-modal-btn:last-child{border-right:none;border-radius:0}.am-modal-btn:first-child:last-child{border-radius:0}.am-modal-btn.am-modal-btn-bold{font-weight:500}.am-modal-btn:active{background:#d4d4d4}.am-modal-btn+.am-modal-btn{border-left:1px solid #dedede}.am-modal-no-btn .am-modal-dialog{border-radius:0;border-bottom:none}.am-modal-no-btn .am-modal-bd{border-bottom:none}.am-modal-no-btn .am-modal-footer{display:none}.am-modal-loading .am-modal-bd{border-bottom:none}.am-modal-loading .am-icon-spin{display:inline-block;font-size:2.4rem}.am-modal-loading .am-modal-footer{display:none}.am-modal-actions{position:fixed;left:0;bottom:0;z-index:1110;width:100%;max-height:100%;overflow-x:hidden;overflow-y:auto;text-align:center;border-radius:0;-webkit-transform:translateY(100%);-ms-transform:translateY(100%);transform:translateY(100%);-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s}.am-modal-actions.am-modal-active{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.am-modal-actions.am-modal-out{z-index:1109;-webkit-transform:translateY(100%);-ms-transform:translateY(100%);transform:translateY(100%)}.am-modal-actions-group{margin:10px}.am-modal-actions-group .am-list{margin:0;border-radius:0}.am-modal-actions-group .am-list>li{margin-bottom:0;border-bottom:none;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,.015);box-shadow:inset 0 1px 0 rgba(0,0,0,.015)}.am-modal-actions-group .am-list>li>a{padding:1rem;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-modal-actions-group .am-list>li:first-child{border-top:none;border-top-right-radius:0;border-top-left-radius:0}.am-modal-actions-group .am-list>li:last-child{border-bottom:none;border-bottom-right-radius:0;border-bottom-left-radius:0}.am-modal-actions-header{padding:1rem;color:#999;font-size:1.4rem}.am-modal-actions-danger{color:#dd514c}.am-modal-actions-danger a{color:inherit}.am-popup{position:fixed;left:0;top:0;width:100%;height:100%;z-index:1110;background:#fff;display:none;overflow:hidden;-webkit-transition-property:-webkit-transform;transition-property:-webkit-transform;transition-property:transform;transition-property:transform,-webkit-transform;-webkit-transform:translateY(100%);-ms-transform:translateY(100%);transform:translateY(100%)}.am-popup.am-modal-active,.am-popup.am-modal-out{-webkit-transition-duration:.3s;transition-duration:.3s}.am-popup.am-modal-active{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.am-popup.am-modal-out{-webkit-transform:translateY(100%);-ms-transform:translateY(100%);transform:translateY(100%)}@media all and (min-width:630px) and (min-height:630px){.am-popup{width:630px;height:630px;left:50%;top:50%;margin-left:-315px;margin-top:-315px;-webkit-transform:translateY(1024px);-ms-transform:translateY(1024px);transform:translateY(1024px)}.am-popup.am-modal-active{-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}.am-popup.am-modal-out{-webkit-transform:translateY(1024px);-ms-transform:translateY(1024px);transform:translateY(1024px)}}.am-popup-inner{padding-top:44px;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.am-popup-hd{position:absolute;top:0;z-index:1000;width:100%;height:43px;border-bottom:1px solid #dedede;background-color:#fff}.am-popup-hd .am-popup-title{font-size:1.8rem;font-weight:700;line-height:43px;text-align:center;margin:0 30px;color:#333;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-popup-hd .am-close{position:absolute;right:10px;top:8px;cursor:pointer;-webkit-transition:all .3s;transition:all .3s;color:#999}.am-popup-hd .am-close:hover{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);color:#555}.am-popup-bd{padding:15px;background:#f8f8f8;color:#555}.am-offcanvas{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:1090;background:rgba(0,0,0,.15)}.am-offcanvas.am-active{display:block}.am-offcanvas-page{position:fixed;-webkit-transition:margin-left .3s ease-in-out;transition:margin-left .3s ease-in-out}.am-offcanvas-bar{position:fixed;top:0;bottom:0;left:0;z-index:1091;width:270px;max-width:100%;background:#333;overflow-y:auto;-webkit-overflow-scrolling:touch;-webkit-transition:-webkit-transform .3s ease-in-out;transition:-webkit-transform .3s ease-in-out;transition:transform .3s ease-in-out;transition:transform .3s ease-in-out,-webkit-transform .3s ease-in-out;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.am-offcanvas-bar:after{content:"";display:block;position:absolute;top:0;bottom:0;right:0;width:1px;background:#262626}.am-offcanvas.am-active .am-offcanvas-bar.am-offcanvas-bar-active{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.am-offcanvas-bar-flip{left:auto;right:0;-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.am-offcanvas-bar-flip:after{right:auto;left:0}.am-offcanvas-content{padding:15px;color:#999}.am-offcanvas-content a{color:#ccc}.am-popover{position:absolute;top:0;left:0;margin:0;border-radius:0;background:#333;color:#fff;border:1px solid #333;display:none;font-size:1.6rem;z-index:1150;opacity:0;-webkit-transition:opacity .3s;transition:opacity .3s}.am-popover.am-active{display:block!important;opacity:1}.am-popover-inner{position:relative;background:#333;padding:8px;z-index:110}.am-popover-caret{position:absolute;top:0;z-index:100;display:inline-block;width:0;height:0;vertical-align:middle;border-bottom:8px solid #333;border-right:8px solid transparent;border-left:8px solid transparent;border-top:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);overflow:hidden}.am-popover-top .am-popover-caret{top:auto;bottom:-8px;-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.am-popover-bottom .am-popover-caret{top:-8px}.am-popover-bottom .am-popover-caret,.am-popover-top .am-popover-caret{left:50%;margin-left:-8px}.am-popover-left .am-popover-caret{top:auto;left:auto;right:-12px;-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.am-popover-right .am-popover-caret{right:auto;left:-12px;-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.am-popover-left .am-popover-caret,.am-popover-right .am-popover-caret{top:50%;margin-top:-4px}.am-popover-sm{font-size:1.4rem}.am-popover-sm .am-popover-inner{padding:5px}.am-popover-lg{font-size:1.8rem}.am-popover-primary{border-color:#0e90d2}.am-popover-primary .am-popover-inner{background:#0e90d2}.am-popover-primary .am-popover-caret{border-bottom-color:#0e90d2}.am-popover-secondary{border-color:#3bb4f2}.am-popover-secondary .am-popover-inner{background:#3bb4f2}.am-popover-secondary .am-popover-caret{border-bottom-color:#3bb4f2}.am-popover-success{border-color:#5eb95e}.am-popover-success .am-popover-inner{background:#5eb95e}.am-popover-success .am-popover-caret{border-bottom-color:#5eb95e}.am-popover-warning{border-color:#F37B1D}.am-popover-warning .am-popover-inner{background:#F37B1D}.am-popover-warning .am-popover-caret{border-bottom-color:#F37B1D}.am-popover-danger{border-color:#dd514c}.am-popover-danger .am-popover-inner{background:#dd514c}.am-popover-danger .am-popover-caret{border-bottom-color:#dd514c}#nprogress{pointer-events:none}#nprogress .nprogress-bar{position:fixed;top:0;left:0;z-index:2000;width:100%;height:2px;background:#5eb95e}#nprogress .nprogress-peg{display:block;position:absolute;right:0;width:100px;height:100%;-webkit-box-shadow:0 0 10px #5eb95e,0 0 5px #5eb95e;box-shadow:0 0 10px #5eb95e,0 0 5px #5eb95e;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .nprogress-spinner{position:fixed;top:15px;right:15px;z-index:2000;display:block}#nprogress .nprogress-spinner-icon{width:18px;height:18px;-webkit-box-sizing:border-box;box-sizing:border-box;border:solid 2px transparent;border-top-color:#5eb95e;border-left-color:#5eb95e;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.am-tabs-bd{position:relative;overflow:hidden;border:1px solid #ddd;border-top:none;z-index:100;-webkit-transition:height .3s;transition:height .3s}.am-tabs-bd:after,.am-tabs-bd:before{content:" ";display:table}.am-tabs-bd:after{clear:both}.am-tabs-bd .am-tab-panel{position:absolute;top:0;z-index:99;float:left;width:100%;padding:10px 10px 15px;visibility:hidden;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.am-tabs-bd .am-tab-panel *{-webkit-user-drag:none}.am-tabs-bd .am-tab-panel.am-active{position:relative;z-index:100;visibility:visible;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.am-tabs-bd .am-tab-panel.am-active~.am-tab-panel{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.am-tabs-bd .am-tabs-bd{border:none}.am-tabs-bd-ofv{overflow:visible}.am-tabs-bd-ofv>.am-tab-panel{display:none}.am-tabs-bd-ofv>.am-tab-panel.am-active{display:block}.am-tabs-fade .am-tab-panel{opacity:0;-webkit-transition:opacity .25s linear;transition:opacity .25s linear}.am-tabs-fade .am-tab-panel.am-in{opacity:1}.am-share{font-size:14px}.am-share-title{padding:10px 0 0;margin:0 10px;font-weight:400;text-align:center;color:#555;background-color:#f8f8f8;border-bottom:1px solid #fff;border-top-right-radius:2px;border-top-left-radius:2px}.am-share-title:after{content:"";display:block;width:100%;height:0;margin-top:10px;border-bottom:1px solid #dfdfdf}.am-share-sns{margin:0 10px;padding-top:15px;background-color:#f8f8f8;border-bottom-right-radius:2px;border-bottom-left-radius:2px}.am-share-sns li{margin-bottom:15px}.am-share-sns a{display:block;color:#555}.am-share-sns span{display:block}.am-share-sns [class*=am-icon]{background-color:#3bb4f2;border-radius:50%;width:36px;height:36px;line-height:36px;color:#fff;margin-bottom:5px;font-size:18px}.am-share-sns .am-icon-weibo{background-color:#ea1328}.am-share-sns .am-icon-qq{background-color:#009cda}.am-share-sns .am-icon-star{background-color:#ffc028}.am-share-sns .am-icon-tencent-weibo{background-color:#23ccfe}.am-share-sns .am-icon-wechat,.am-share-sns .am-icon-weixin{background-color:#44b549}.am-share-sns .am-icon-renren{background-color:#105ba3}.am-share-sns .am-icon-comment{background-color:#5eb95e}.am-share-footer{margin:10px}.am-share-footer .am-btn{color:#555}.am-share-wechat-qr{font-size:14px;color:#777}.am-share-wechat-qr .am-modal-dialog{background-color:#fff;border:1px solid #dedede}.am-share-wechat-qr .am-modal-hd{padding-top:10px;text-align:left;margin-bottom:10px}.am-share-wechat-qr .am-share-wx-qr{margin-bottom:10px}.am-share-wechat-qr .am-share-wechat-tip{text-align:left}.am-share-wechat-qr .am-share-wechat-tip em{color:#dd514c;font-weight:700;font-style:normal;margin-left:3px;margin-right:3px}.am-pureview{position:fixed;left:0;top:0;bottom:0;right:0;z-index:1120;width:100%;height:100%;background:rgba(0,0,0,.95);display:none;overflow:hidden;-webkit-transition:-webkit-transform .3s;transition:-webkit-transform .3s;transition:transform .3s;transition:transform .3s,-webkit-transform .3s;-webkit-transform:translate(0,100%);-ms-transform:translate(0,100%);transform:translate(0,100%)}.am-pureview.am-active{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.am-pureview ol,.am-pureview ul{list-style:none;padding:0;margin:0;width:100%}.am-pureview-slider{overflow:hidden;height:100%}.am-pureview-slider li{position:absolute;width:100%;height:100%;top:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center;vertical-align:middle;-webkit-transition:all .3s linear;transition:all .3s linear;z-index:100;visibility:hidden}.am-pureview-slider li.am-pureview-slide-prev{-webkit-transform:translate(-100%,0);-ms-transform:translate(-100%,0);transform:translate(-100%,0);z-index:109}.am-pureview-slider li.am-pureview-slide-next{-webkit-transform:translate(100%,0);-ms-transform:translate(100%,0);transform:translate(100%,0);z-index:109}.am-pureview-slider li.am-active{position:relative;z-index:110;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);visibility:visible}.am-pureview-slider .pinch-zoom-container{width:100%;z-index:1121}.am-pureview-slider .am-pinch-zoom{position:relative;width:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}.am-pureview-slider .am-pinch-zoom:after{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f110";-webkit-animation:icon-spin 2s infinite linear;animation:icon-spin 2s infinite linear;font-size:24px;line-height:24px;color:#eee;position:absolute;top:50%;left:50%;margin-left:-12px;margin-top:-12px;z-index:1}.am-pureview-slider .am-pinch-zoom.am-pureview-loaded:after{display:none}.am-pureview-slider img{position:relative;display:block;max-width:100%;max-height:100%;opacity:0;z-index:200;-webkit-user-drag:none;-webkit-transition:opacity .2s ease-in;transition:opacity .2s ease-in}.am-pureview-slider img.am-img-loaded{opacity:1}.am-pureview-direction{position:absolute;top:50%;width:100%;margin-top:-18px!important;z-index:1122}.am-pureview-only .am-pureview-direction,.am-touch .am-pureview-direction{display:none}.am-pureview-direction li{position:absolute;width:36px;height:36px}.am-pureview-direction a{display:block;height:36px;border:none;color:#ccc;opacity:.5;cursor:pointer;text-align:center;z-index:1125}.am-pureview-direction a:before{content:"\f137";line-height:36px;font-size:24px}.am-pureview-direction a:hover{opacity:1}.am-pureview-direction .am-pureview-prev{left:15px}.am-pureview-direction .am-pureview-next{right:15px}.am-pureview-direction .am-pureview-next a:before{content:"\f138"}.am-pureview-bar{position:absolute;bottom:0;height:45px;width:100%;background-color:rgba(0,0,0,.35);color:#eee;line-height:45px;padding:0 10px;font-size:14px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.am-pureview-bar .am-pureview-title{display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;margin-left:6px;-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.am-pureview-bar .am-pureview-total{font-size:10px;line-height:48px}.am-pureview-actions{position:absolute;z-index:1130;left:0;right:0;top:0;height:45px;background-color:rgba(0,0,0,.35)}.am-pureview-actions a{position:absolute;left:10px;color:#ccc;display:block;width:45px;line-height:45px;text-align:left;font-size:16px}.am-pureview-actions a:hover{color:#fff}.am-pureview-actions [data-am-toggle=share]{left:auto;right:10px}.am-pureview-actions,.am-pureview-bar{opacity:0;-webkit-transition:all .15s;transition:all .15s;z-index:1130}.am-pureview-bar-active .am-pureview-actions,.am-pureview-bar-active .am-pureview-bar{opacity:1}.am-pureview-nav{position:absolute;bottom:15px;left:0;right:0;text-align:center;z-index:1131}.am-pureview-bar-active .am-pureview-nav{display:none}.am-pureview-nav li{display:inline-block;background:#ccc;background:rgba(255,255,255,.5);width:8px;height:8px;margin:0 3px;border-radius:50%;text-indent:-9999px;overflow:hidden;cursor:pointer}.am-pureview-nav .am-active{background:#fff;background:rgba(255,255,255,.9)}[data-am-pureview] img{cursor:pointer}.am-pureview-active{overflow:hidden}.ath-viewport *{-webkit-box-sizing:border-box;box-sizing:border-box}.ath-viewport{position:relative;z-index:2147483641;pointer-events:none;-webkit-tap-highlight-color:rgba(0,0,0,0);-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none}.ath-modal{pointer-events:auto!important;background:rgba(0,0,0,.6)}.ath-mandatory{background:#000}.ath-container{pointer-events:auto!important;position:absolute;z-index:2147483641;padding:.7em .6em;width:18em;background:#eee;-webkit-background-size:100% auto;background-size:100% auto;-webkit-box-shadow:0 .2em 0 #d1d1d1;box-shadow:0 .2em 0 #d1d1d1;font-family:sans-serif;font-size:15px;line-height:1.5em;text-align:center}.ath-container small{font-size:.8em;line-height:1.3em;display:block;margin-top:.5em}.ath-ios.ath-phone{bottom:1.8em;left:50%;margin-left:-9em}.ath-ios6.ath-tablet{left:5em;top:1.8em}.ath-ios7.ath-tablet{left:.7em;top:1.8em}.ath-ios8.ath-tablet{right:.4em;top:1.8em}.ath-android{bottom:1.8em;left:50%;margin-left:-9em}.ath-container:before{content:'';position:relative;display:block;float:right;margin:-.7em -.6em 0 .5em;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAMAAABmmnOVAAAAdVBMVEUAAAA5OTkzMzM7Ozs3NzdBQUFAQEA/Pz8+Pj5BQUFAQEA/Pz8+Pj5BQUFAQEA/Pz9BQUE+Pj4/Pz8/Pz8+Pj4/Pz8/Pz8/Pz8+Pj4/Pz8+Pj4/Pz8/Pz8/Pz8/Pz8/Pz8+Pj4/Pz8/Pz8/Pz8/Pz9AQEA/Pz+fdCaPAAAAJnRSTlMACQoNDjM4OTo7PEFCQ0RFS6ytsbS1tru8vcTFxu7x8vX19vf4+C5yomAAAAJESURBVHgBvdzLTsJAGEfxr4C2KBcVkQsIDsK8/yPaqIsPzVlyzrKrX/5p0kkXEz81L23otc9NpIbbWia2YVLqdnhlqFlhGWpSDHe1aopsSIpRb8gK0dC3G30b9rVmhWZIimTICsvQtx/FsuYOrWHoDjX3Gu31gzJxdki934WrAIOsAIOsAIOiAMPhPsJTgKGN0BVsYIVsYIVpYIVpYIVpYIVpYIVpYIVpYIVpYIVlAIVgEBRs8BRs8BRs8BRs8BRs8BRs8BRs8BRTNmgKNngKNngKNngKNngKNhiKGxgiOlZoBlaYBlaYBlaYBlaYBlaYBlaYBlaYBlZIBlBMfQMrVAMr2KAqBENSHFHhGEABhi5CV6gGUKgGUKgGUKgGUFwuqgEUvoEVsoEVpoEUpgEUggF+gKTKY+h1fxSlC7/Z+RrxOQ3fcEoAPPHZBlaYBlaYBlaYBlZYBlYIhvLBCstw7PgM7hkiWOEZWGEaWGEaWGEaIsakEAysmHkGVpxmvoEVqoEVpoEVpoEVpoEVpoEVpoEVkoEVgkFQsEFSsEFQsGEcoSvY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnY4CnmbNAUT2c2WAo2eAo2eAo2eAo2eAo2eArNEPFACjZ4CjZ4CjZ4CjaIird/rBvFH6llNCvewdli1URWCIakSIZesUaDoFg36dKFWk9zCZDei3TtwmCj7pC22AwikiIZPEU29IpFNliKxa/hC9DFITjQPYhcAAAAAElFTkSuQmCC);background-color:rgba(255,255,255,.8);-webkit-background-size:50% 50%;background-size:50%;background-repeat:no-repeat;background-position:50%;width:2.7em;height:2.7em;text-align:center;overflow:hidden;color:#a33;z-index:2147483642}.ath-container.ath-icon:before{position:absolute;top:0;right:0;margin:0;float:none}.ath-mandatory .ath-container:before{display:none}.ath-container.ath-android:before{float:left;margin:-.7em .5em 0 -.6em}.ath-container.ath-android.ath-icon:before{position:absolute;right:auto;left:0;margin:0;float:none}.ath-action-icon{display:inline-block;vertical-align:middle;background-position:50%;background-repeat:no-repeat;text-indent:-9999em;overflow:hidden}.ath-ios7 .ath-action-icon,.ath-ios8 .ath-action-icon{width:1.6em;height:1.6em;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAACtCAYAAAB7l7tOAAAF6UlEQVR4AezZWWxUZRiH8VcQEdxZEFFiUZBFUCIa1ABBDARDcCciYGKMqTEGww3SOcNSAwQTjOBiiIpEhRjAhRgXRC8MFxojEhAFZUGttVhaoSxlaW3n8W3yXZxm6vTrOMM5Q98n+V9MMu1pvl++uZhKuypghu49KaaTWGdZSYoVN6VD95nMpLNYZ9XNbdQR2od2k88O3Gm6Bh0t7H0p5Vwp2Ax3ajpu2tYbciFWwkTFO63DY6+JcI4USFaSyYpWp8N7SVZJKR3EinkBk9JxvZFXxhnZSjBaoWp1ZL0ES8WKYXMZp0AndORgy8WKFe5Yf1zvvSBWDEpys2LU6MjD5kmEWQlGKsJRHXlcqUSQVcItEnDEA6gAb7LhjvD9WO6yIEfICQI5A1nzGCYB1T4og5bBiFcyv2f6ujYhl4iVxwKG6qp8MK55HsqPwK0rMr9v/yEo3uCPrJstVh5KMER30Aeh31Ioq0FrHfjXw9CYghnrvYFTuqfEymFzGSwBlT4ARYr7u+K6GLmCVGvAGg2NMG0d/sgJnpScZLjXSkC5z8H3eQ72/k24Q8NfzvwFyK4qtuJSZKaubRPyE/K/Mtx+EvCHL+7uasId1t10w0scz/RzSzYzAfgKV30D3LPaG7lRkR8RK4tKKJKAMp+D7r0EfmmOe0x3m2itAc/ZxBjgAt1mXHWKPPkdb+QGSTJdrDaU5EoJ2OtzwD0WwY7KNNzbRfMFFg24WPdtGHnS221Cflgsj56hjwTs8TnY7oq7/QDhjutGicsb2AVcovsO18l6uPPNNiE/JFaGAq7Q7fY50G4LYVtz3FrdaNGyBXbIl+q24DqhyHes9EaulwR3SwtZs+ktAT/7HORliru1gnCndONFyx44Dfn7MPLYN7yR6yTJZAllJeguAT/4HOBFz8I3ZWm4E0TLFbBD7qn7EVdtHYx53R9ZN0ksrZRuErDN5+AuLIWvm+Oe1k0ULdfADrmX7idcR0/DyBXeyCdlLuMMOGCBz4F1ng+f7yFcve5e0fIFHELeiav6BAx70Rt5p0yhY3u/wR0kyarW/uX35b403PtFyzewQ75ctwtXzSkY8WqruHslSV8RscrL6TJ1bcvfWJ0/HzbtIdw/ugdFyzdwOOAq3T6fmzxwGQ3vbmO8iFioIWqYSsHMj9M/ljfuTsOdItoZBXYBfXX7cVXVwvXLm/8+fU3lcdCqdEMNGBbgUmRmfQISQKd5sGEn4VK6YtEiAXYBA3QVuA4q8hCHrDcafR1ul65jewfuovsCl7vJrNlOuEbdo6JFCuwCrtb9hqusBu56Cw4cI1y1briIWEBn3Ue0XKPuMdGiBg4H9NdV0HJ/6QZLOEPmPN0GmpfSPS5arIBdwHUtIFfoBsl/ZsgfhHCfFi2WwC5goO4AmvanbqBkzJA76tboZokWa2AXMEi3RTdAvDLkDqJFAhzB32xFD2wZsGXA0WfAlgFbBmwZsGXAlgFbBpzk04JaKb0iA9ZnF9x5SQAFtRKKIgPWZxfaeRmwAZ/BGbAB37eaG6MCbnq2Aed5czYyKirgpmcbsAHHZAZswN0Wwo7KeG1fFf2jAm56dtzOQ42yB+65mDhWFBUwUETMUiMDNmADbp/APRaTAh6I2bpGCNw1bufRZJQ1cPdF/NueHZsgDEBBGLbMGoIu4AZu5gLOZeEaYmEXeznF3jRPyEv4frgJvvJe3qTefY0AAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwYMGDBgwIABAwb8rwADBgwYMGDAgAEDBgwYMGDAgAEDBgwYMGDAgAEDBgz4/sz1Nia/9hizA7zgklwy3RYwYMBzBRjw4bPjxAbAAizAAtwgwAIswAIswAIMGDBgARZgARZgAS4FWIAFWIAFWIABAwYswAIswAIswIUAC7AAC7AACzBgwIAFWIAFWIAFuBBgARZgARZgAQYMGPApQ99ZCdgWtzqwATbABtgAG2DbnxNb7zbRimsMLMACrDf2wMWI/WasfQAAAABJRU5ErkJggg==);margin-top:-.3em;-webkit-background-size:auto 100%;background-size:auto 100%}.ath-ios6 .ath-action-icon{width:1.8em;height:1.8em;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAAB0CAQAAADAmnOnAAAAAnNCSVQICFXsRgQAAAAJcEhZcwAAWwEAAFsBAXkZiFwAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAF4klEQVR4Ae3a/a+XdR3H8ec5HM45HDmKICoVohkZsxESRRCzcZM/2JKkdGR5MrSkleA0Pd00O4u5IVuNM2yYc6XSzCExU4oUNRPCJFdMUAhsYZpUGhscOHA4N8/WZzsL6HBxvofvdV3fa3yer//gsV3vH659KHzncBsJxUYhDzOEhCKQbORs+ip2wzgM+wvj+P9i35qAGLaHGcQSgKSTrxBLABJppZpYApCspoFYApBsZjSxBCD5OxOJJQBJG1cQSwCSLpqJJQCJ3MvgCGTinuSMCJS8LZwfgZL3FtMiUPIOcU0ESl4PLRHoRPsJtREoeRsYGYGS9yrvo6RmpbLaigWSfzOdErLs6+bLUMFA0sF1+QF1cz1UNlBYK9V5AHXyWSgEkKyiIWOgGh829Ki1lLcaxjCVK7mJRSxjBY+zgRf/u9pXcMB7jhEZAg32EUP3O6hMKOP5Iq2sZQeHMZXt5KKMgOpcY+iHVnFyjeQKlrCBdsxge5ieAVC9vzLUelI8H+A7bKIHM10H81IGGuKvDf1ggDxVTKOV1zG3/Yia1ICG+ltD32MgNTKfP2HuW0VDKkCNrjfUTOm9i6XswwrZJkaVHeh0f2fodkrtfO6jAytqrzG+rEDDfVG1x1sprZEs5RBW4PZxeT+Bbrf5hPu9arfzKaU6WjiAFbseWvoF1GW/6vYGSmkyW7Dit4xB5QHq9Br6Xx2t9GAhtp6zkoHsfNp1J9wX6H+jeR4LtJc4LxGopZZyNpN/YcG2mw9nBTSPLizgOmjKAujGgvJID3ekD7QYi7nGzkvmQtpA38Vi7iJf0TedlC7QTVjMfcY2QyvSBPpUMW/PIBfbo9pls1XpAX2EdizeznStob3OJpQO0DB2YfE21q2GtnghpAm0Gou3T9tm6BGHQppA12HRVt17eboNlydNoLHsx2JtmL801OYcQmkC/QKLtQt9ydBW3wNpA30ci7Ur3WdolUMhbaBqNhf/8qQJ9Hkszs5wjaH9XkUobaAqtmFRdoGbDb3sWMgG6DIs5852knO82RaXer+P+qyb3eWeo7ZNBrRZvm1otY2QFdBjeHIb6hTne49Put12+9ObMoDdYmfy5UkF6AK6cCCr9aM2u9IddptcOYCG+FNDB5xLKCugO7G01TndFp/xgAntdYvrfdwVLnORt3q9Vx25F27DUjbGPxr6qxMgW6Cd2N+d6wLXedA+6nKbK73Lr/pJxzusvE/wZrvX0FOOgGyBxmF/dprXutYOj6nNdS6xyYnWp/dGcaGdhr5vDWQN9E1MXrUzfcA2j2qPj/l1J1uT9iPOeh8w1O7nCGUN9HzyGZ7ndo9qp0ucanU2r1xH+wdDu5wIeQDVVx0+/kd1i697RNv8thdn+Qz4Uv9p6DeOhHyApmBfq3OBu+3Nfd7nVELZAX3Nw4ZarYG8gG7GY1dlk6/Zm3/2Rk8jlB1QvT82dNAmQjkBVf8Mj957fdrefM7ZVhPKEuidvmDob06CXIGGbsX/bZDf8KAhfdbJhLIGmuZuQ084HHIGatiLvRvrRkP6qldbBXkAzbfD0N0OhryBGqrEMOd50FC7d1hPKGugBh8ydMh5hPIGGouI1d5lj6F1vptQ9kDvcKOhN5wMlQH0QcRGnzC03yZCeQDN9G1D6xwBFQI07FI8x02GdjgB8gJqttPQcmuhYoAumzvG7YZWejrkA1TrPYYO+SVCFQO0aM4bqj0uJJQH0LluSP7PkyeQU9QOmyAvoBm+Zegpz4LKA/qYB/wE5AXUe3m81zqoRKAPOYWcuvP9dxvqcD6h7IAKkaNU3eUlHLcI9EzS5YlAi62h/zUy89QCqqKUmvgHywsJlEHnsQYxAvXVIJo5gIhnPhiBju1iNmLvLn85Ah1ZPYs5jBGo72awEzEC9dVwHqQHI9DxWoAYgSLQQKteGIESu/qhCJTYtT+PQBEoAkWgCBSBkotAEehUWwSKQBEoAkWg/BeBIlAEikARKAJFoFmealu4gVLy1Gt5dkARKAL9BzujPSurTmu/AAAAAElFTkSuQmCC);margin-bottom:.4em;-webkit-background-size:100% auto;background-size:100% auto}.ath-android .ath-action-icon{width:1.4em;height:1.4em;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAANlBMVEVmZmb///9mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZW6fJrAAAAEXRSTlMAAAYHG21ub8fLz9DR8/T4+RrZ9owAAAB3SURBVHja7dNLDoAgDATQWv4gKve/rEajJOJiWLgg6WzpSyB0aHqHiNj6nL1lovb4C+hYzkSNAT7mryQFAVOeGAj4CjwEtgrWXpD/uZKtwEJApXt+Vn0flzRhgNiFZQkOXY0aADQZCOCPlsZJ46Rx0jhp3IiN2wGDHhxtldrlwQAAAABJRU5ErkJggg==);-webkit-background-size:100% auto;background-size:100% auto}.ath-container p{margin:0;padding:0;position:relative;z-index:2147483642;text-shadow:0 .1em 0 #fff;font-size:1.1em}.ath-ios.ath-phone:after{content:'';background:#eee;position:absolute;width:2em;height:2em;bottom:-.9em;left:50%;margin-left:-1em;-webkit-transform:scaleX(.9) rotate(45deg);-ms-transform:scaleX(.9) rotate(45deg);transform:scaleX(.9) rotate(45deg);-webkit-box-shadow:.2em .2em 0 #d1d1d1;box-shadow:.2em .2em 0 #d1d1d1}.ath-ios.ath-tablet:after{content:'';background:#eee;position:absolute;width:2em;height:2em;top:-.9em;left:50%;margin-left:-1em;-webkit-transform:scaleX(.9) rotate(45deg);-ms-transform:scaleX(.9) rotate(45deg);transform:scaleX(.9) rotate(45deg);z-index:2147483641}.ath-application-icon{position:relative;padding:0;border:0;margin:0 auto .2em auto;height:6em;width:6em;z-index:2147483642}.ath-container.ath-ios .ath-application-icon{border-radius:1em;-webkit-box-shadow:0 .2em .4em rgba(0,0,0,.3),inset 0 .07em 0 rgba(255,255,255,.5);box-shadow:0 .2em .4em rgba(0,0,0,.3),inset 0 .07em 0 rgba(255,255,255,.5);margin:0 auto .4em auto}@media only screen and (orientation:landscape){.ath-container.ath-phone{width:24em}.ath-android.ath-phone{margin-left:-12em}.ath-ios.ath-phone{margin-left:-12em}.ath-ios6:after{left:39%}.ath-ios8.ath-phone{left:auto;bottom:auto;right:.4em;top:1.8em}.ath-ios8.ath-phone:after{bottom:auto;top:-.9em;left:68%;z-index:2147483641;-webkit-box-shadow:none;box-shadow:none}}.am-checkbox,.am-checkbox-inline,.am-radio,.am-radio-inline{padding-left:22px;position:relative;-webkit-transition:color .25s linear;transition:color .25s linear;font-size:14px;line-height:1.5}label.am-checkbox,label.am-radio{font-weight:400}.am-ucheck-icons{color:#999;display:block;height:20px;top:0;left:0;position:absolute;width:20px;text-align:center;line-height:21px;font-size:18px;cursor:pointer}.am-checkbox .am-icon-checked,.am-checkbox .am-icon-unchecked,.am-checkbox-inline .am-icon-checked,.am-checkbox-inline .am-icon-unchecked,.am-radio .am-icon-checked,.am-radio .am-icon-unchecked,.am-radio-inline .am-icon-checked,.am-radio-inline .am-icon-unchecked{position:absolute;left:0;top:0;display:inline-table;margin:0;background-color:transparent;-webkit-transition:color .25s linear;transition:color .25s linear}.am-checkbox .am-icon-checked:before,.am-checkbox .am-icon-unchecked:before,.am-checkbox-inline .am-icon-checked:before,.am-checkbox-inline .am-icon-unchecked:before,.am-radio .am-icon-checked:before,.am-radio .am-icon-unchecked:before,.am-radio-inline .am-icon-checked:before,.am-radio-inline .am-icon-unchecked:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.am-checkbox .am-icon-checked,.am-checkbox-inline .am-icon-checked,.am-radio .am-icon-checked,.am-radio-inline .am-icon-checked{opacity:0}.am-checkbox .am-icon-checked:before,.am-checkbox-inline .am-icon-checked:before{content:"\f046"}.am-checkbox .am-icon-unchecked:before,.am-checkbox-inline .am-icon-unchecked:before{content:"\f096"}.am-radio .am-icon-checked:before,.am-radio-inline .am-icon-checked:before{content:"\f192"}.am-radio .am-icon-unchecked:before,.am-radio-inline .am-icon-unchecked:before{content:"\f10c"}.am-ucheck-checkbox,.am-ucheck-radio{position:absolute;left:0;top:0;margin:0;padding:0;width:20px;height:20px;opacity:0;outline:0!important}.am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons{color:#0e90d2}.am-ucheck-checkbox:checked+.am-ucheck-icons,.am-ucheck-radio:checked+.am-ucheck-icons{color:#0e90d2}.am-ucheck-checkbox:checked+.am-ucheck-icons .am-icon-unchecked,.am-ucheck-radio:checked+.am-ucheck-icons .am-icon-unchecked{opacity:0}.am-ucheck-checkbox:checked+.am-ucheck-icons .am-icon-checked,.am-ucheck-radio:checked+.am-ucheck-icons .am-icon-checked{opacity:1}.am-ucheck-checkbox:disabled+.am-ucheck-icons,.am-ucheck-radio:disabled+.am-ucheck-icons{cursor:default;color:#d8d8d8}.am-ucheck-checkbox:disabled:checked+.am-ucheck-icons .am-icon-unchecked,.am-ucheck-radio:disabled:checked+.am-ucheck-icons .am-icon-unchecked{opacity:0}.am-ucheck-checkbox:disabled:checked+.am-ucheck-icons .am-icon-checked,.am-ucheck-radio:disabled:checked+.am-ucheck-icons .am-icon-checked{opacity:1;color:#d8d8d8}.am-checkbox-inline.am-secondary .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox-inline.am-secondary .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-secondary .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-secondary .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-secondary .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-secondary .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-secondary .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-secondary .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons{color:#3bb4f2}.am-checkbox-inline.am-secondary .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox-inline.am-secondary .am-ucheck-radio:checked+.am-ucheck-icons,.am-checkbox.am-secondary .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox.am-secondary .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio-inline.am-secondary .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio-inline.am-secondary .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio.am-secondary .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio.am-secondary .am-ucheck-radio:checked+.am-ucheck-icons{color:#3bb4f2}.am-checkbox-inline.am-success .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox-inline.am-success .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-success .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-success .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-success .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-success .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-success .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-success .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons{color:#5eb95e}.am-checkbox-inline.am-success .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox-inline.am-success .am-ucheck-radio:checked+.am-ucheck-icons,.am-checkbox.am-success .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox.am-success .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio-inline.am-success .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio-inline.am-success .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio.am-success .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio.am-success .am-ucheck-radio:checked+.am-ucheck-icons{color:#5eb95e}.am-checkbox-inline.am-warning .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox-inline.am-warning .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-warning .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-warning .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-warning .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-warning .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-warning .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-warning .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons{color:#F37B1D}.am-checkbox-inline.am-warning .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox-inline.am-warning .am-ucheck-radio:checked+.am-ucheck-icons,.am-checkbox.am-warning .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox.am-warning .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio-inline.am-warning .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio-inline.am-warning .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio.am-warning .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio.am-warning .am-ucheck-radio:checked+.am-ucheck-icons{color:#F37B1D}.am-checkbox-inline.am-danger .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox-inline.am-danger .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-danger .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-checkbox.am-danger .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-danger .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio-inline.am-danger .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-danger .am-ucheck-checkbox:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons,.am-radio.am-danger .am-ucheck-radio:hover:not(.am-nohover):not(:disabled)+.am-ucheck-icons{color:#dd514c}.am-checkbox-inline.am-danger .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox-inline.am-danger .am-ucheck-radio:checked+.am-ucheck-icons,.am-checkbox.am-danger .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-checkbox.am-danger .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio-inline.am-danger .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio-inline.am-danger .am-ucheck-radio:checked+.am-ucheck-icons,.am-radio.am-danger .am-ucheck-checkbox:checked+.am-ucheck-icons,.am-radio.am-danger .am-ucheck-radio:checked+.am-ucheck-icons{color:#dd514c}.am-field-error+.am-ucheck-icons{color:#dd514c}.am-field-valid+.am-ucheck-icons{color:#5eb95e}.am-selected{width:200px}.am-selected-btn{width:100%;padding-left:10px;text-align:right}.am-selected-btn.am-btn-default{background:0 0}.am-invalid .am-selected-btn{border-color:#dd514c}.am-selected-header{height:45px;background-color:#f2f2f2;border-bottom:1px solid #ddd;display:none}.am-selected-status{text-align:left;width:100%;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-selected-content{padding:10px 0}.am-selected-search{padding:0 10px 10px}.am-selected-search .am-form-field{padding:.5em}.am-selected-list{margin:0;padding:0;list-style:none;font-size:1.5rem}.am-selected-list li{position:relative;cursor:pointer;padding:5px 10px;-webkit-transition:background-color .15s;transition:background-color .15s}.am-selected-list li:hover{background-color:#f8f8f8}.am-selected-list li:hover .am-icon-check{opacity:.6}.am-selected-list li.am-checked .am-icon-check{opacity:1;color:#0e90d2}.am-selected-list li.am-disabled{opacity:.5;pointer-events:none;cursor:not-allowed}.am-selected-list .am-selected-list-header{margin-top:8px;font-size:1.3rem;color:#999;border-bottom:1px solid #e5e5e5;cursor:default}.am-selected-list .am-selected-list-header:hover{background:0 0}.am-selected-list .am-selected-list-header:first-child{margin-top:0}.am-selected-list .am-selected-text{display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;margin-right:30px}.am-selected-list .am-icon-check{position:absolute;right:8px;top:5px;color:#999;opacity:0;-webkit-transition:opacity .15s;transition:opacity .15s}.am-selected-hint{line-height:1.2;color:#dd514c}.am-selected-hint:not(:empty){margin-top:10px;border-top:1px solid #e5e5e5;padding:10px 10px 0}.am-selected-placeholder{opacity:.65}.am-fade{opacity:0;-webkit-transition:opacity .2s linear;transition:opacity .2s linear}.am-fade.am-in{opacity:1}.am-collapse{display:none}.am-collapse.am-in{display:block}tr.am-collapse.am-in{display:table-row}tbody.am-collapse.am-in{display:table-row-group}.am-collapsing{position:relative;height:0;overflow:hidden;-webkit-transition:height .3s ease;transition:height .3s ease}.am-sticky{position:fixed!important;z-index:1010;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}[data-am-sticky][class*=am-animation-]{-webkit-animation-duration:.2s;animation-duration:.2s}.am-dimmer-active{overflow:hidden}.am-dimmer{position:fixed;top:0;right:0;bottom:0;left:0;display:none;width:100%;height:100%;background-color:rgba(0,0,0,.6);z-index:1100;opacity:0}.am-dimmer.am-active{opacity:1}[data-am-collapse]{cursor:pointer}.am-datepicker{top:0;left:0;border-radius:0;background:#fff;-webkit-box-shadow:0 0 10px #ccc;box-shadow:0 0 10px #ccc;padding-bottom:10px;margin-top:10px;width:238px;color:#555;display:none}.am-datepicker>div{display:none}.am-datepicker table{width:100%}.am-datepicker tr.am-datepicker-header{font-size:1.6rem;color:#fff;background:#3bb4f2}.am-datepicker td,.am-datepicker th{text-align:center;font-weight:400;cursor:pointer}.am-datepicker th{height:48px}.am-datepicker td{font-size:1.4rem}.am-datepicker td.am-datepicker-day{height:34px;width:34px}.am-datepicker td.am-datepicker-day:hover{background:#F0F0F0;height:34px;width:34px}.am-datepicker td.am-datepicker-day.am-disabled{cursor:no-drop;color:#999;background:#fafafa}.am-datepicker td.am-datepicker-new,.am-datepicker td.am-datepicker-old{color:#89d7ff}.am-datepicker td.am-active,.am-datepicker td.am-active:hover{border-radius:0;color:#0084c7;background:#F0F0F0}.am-datepicker td span{display:block;width:79.33px;height:40px;line-height:40px;float:left;cursor:pointer}.am-datepicker td span:hover{background:#F0F0F0}.am-datepicker td span.am-active{color:#0084c7;background:#F0F0F0}.am-datepicker td span.am-disabled{cursor:no-drop;color:#999;background:#fafafa}.am-datepicker td span.am-datepicker-old{color:#89d7ff}.am-datepicker .am-datepicker-dow{height:40px;color:#0c80ba}.am-datepicker-caret{display:block!important;display:inline-block;width:0;height:0;vertical-align:middle;border-bottom:7px solid #3bb4f2;border-right:7px solid transparent;border-left:7px solid transparent;border-top:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);position:absolute;top:-7px;left:6px}.am-datepicker-right .am-datepicker-caret{left:auto;right:7px}.am-datepicker-up .am-datepicker-caret{top:auto;bottom:-7px;display:inline-block;width:0;height:0;vertical-align:middle;border-top:7px solid #fff;border-right:7px solid transparent;border-left:7px solid transparent;border-bottom:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg)}.am-datepicker-select{height:34px;line-height:34px;text-align:center;-webkit-transition:background-color .3s ease-out;transition:background-color .3s ease-out}.am-datepicker-select:hover{background:rgba(154,217,248,.5);color:#0c80ba}.am-datepicker-next,.am-datepicker-prev{width:34px;height:34px}.am-datepicker-next-icon,.am-datepicker-prev-icon{width:34px;height:34px;line-height:34px;display:inline-block;-webkit-transition:background-color .3s ease-out;transition:background-color .3s ease-out}.am-datepicker-next-icon:hover,.am-datepicker-prev-icon:hover{background:rgba(154,217,248,.5);color:#0c80ba}.am-datepicker-prev-icon:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053"}.am-datepicker-next-icon:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f054"}.am-datepicker-dropdown{position:absolute;z-index:1120}@media only screen and (max-width:640px){.am-datepicker{width:100%}.am-datepicker td span{width:33.33%}.am-datepicker-caret{display:none!important}.am-datepicker-next,.am-datepicker-prev{width:44px;height:44px}}.am-datepicker-success tr.am-datepicker-header{background:#5eb95e}.am-datepicker-success td.am-datepicker-day.am-disabled{color:#999}.am-datepicker-success td.am-datepicker-new,.am-datepicker-success td.am-datepicker-old{color:#94df94}.am-datepicker-success td.am-active,.am-datepicker-success td.am-active:hover{color:#1b961b}.am-datepicker-success td span.am-datepicker-old{color:#94df94}.am-datepicker-success td span.am-active{color:#1b961b}.am-datepicker-success .am-datepicker-caret{border-bottom-color:#5eb95e}.am-datepicker-success .am-datepicker-dow{color:#367b36}.am-datepicker-success .am-datepicker-next-icon:hover,.am-datepicker-success .am-datepicker-prev-icon:hover,.am-datepicker-success .am-datepicker-select:hover{background:rgba(165,216,165,.5);color:#367b36}.am-datepicker-danger tr.am-datepicker-header{background:#dd514c}.am-datepicker-danger td.am-datepicker-day.am-disabled{color:#999}.am-datepicker-danger td.am-datepicker-new,.am-datepicker-danger td.am-datepicker-old{color:#f59490}.am-datepicker-danger td.am-active,.am-datepicker-danger td.am-active:hover{color:#c10802}.am-datepicker-danger td span.am-datepicker-old{color:#f59490}.am-datepicker-danger td span.am-active{color:#c10802}.am-datepicker-danger .am-datepicker-caret{border-bottom-color:#dd514c}.am-datepicker-danger .am-datepicker-dow{color:#a4241f}.am-datepicker-danger .am-datepicker-next-icon:hover,.am-datepicker-danger .am-datepicker-prev-icon:hover,.am-datepicker-danger .am-datepicker-select:hover{background:rgba(237,164,162,.5);color:#a4241f}.am-datepicker-warning tr.am-datepicker-header{background:#F37B1D}.am-datepicker-warning td.am-datepicker-day.am-disabled{color:#999}.am-datepicker-warning td.am-datepicker-new,.am-datepicker-warning td.am-datepicker-old{color:#ffad6d}.am-datepicker-warning td.am-active,.am-datepicker-warning td.am-active:hover{color:#aa4b00}.am-datepicker-warning td span.am-datepicker-old{color:#ffad6d}.am-datepicker-warning td span.am-active{color:#aa4b00}.am-datepicker-warning .am-datepicker-caret{border-bottom-color:#F37B1D}.am-datepicker-warning .am-datepicker-dow{color:#a14c09}.am-datepicker-warning .am-datepicker-next-icon:hover,.am-datepicker-warning .am-datepicker-prev-icon:hover,.am-datepicker-warning .am-datepicker-select:hover{background:rgba(248,180,126,.5);color:#a14c09}.am-datepicker>div{display:block}.am-datepicker>div span.am-datepicker-hour{width:59.5px}.am-datepicker-date{display:block}.am-datepicker-date.am-input-group{display:table}.am-datepicker-time-box{padding:30px 0 30px 0}.am-datepicker-time-box strong{font-size:5.2rem;display:inline-block;height:70px;width:70px;line-height:70px;font-weight:400}.am-datepicker-time-box strong:hover{border-radius:4px;background:#ECECEC}.am-datepicker-time-box em{display:inline-block;height:70px;width:20px;line-height:70px;font-size:5.2rem;font-style:normal}.am-datepicker-toggle{text-align:center;cursor:pointer;padding:10px 0}.am-datepicker-toggle:hover{background:#f0f0f0}@media print{*,:after,:before{background:0 0!important;color:#000!important;-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" [" attr(title) "] "}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}@page{margin:.5cm}select{background:#fff!important}.am-topbar{display:none}.am-table td,.am-table th{background-color:#fff!important}.am-table{border-collapse:collapse!important}.am-table-bordered td,.am-table-bordered th{border:1px solid #ddd!important}}.am-print-block{display:none!important}@media print{.am-print-block{display:block!important}}.am-print-inline{display:none!important}@media print{.am-print-inline{display:inline!important}}.am-print-inline-block{display:none!important}@media print{.am-print-inline-block{display:inline-block!important}}@media print{.am-print-hide{display:none!important}}.lte9 #nprogress .nprogress-spinner{display:none!important}.lte8 .am-dimmer{background-color:#000;filter:alpha(opacity=60)}.lte8 .am-modal-actions{display:none}.lte8 .am-modal-actions.am-modal-active{display:block}.lte8 .am-offcanvas.am-active{background:#000}.lte8 .am-popover .am-popover-caret{border:8px solid transparent}.lte8 .am-popover-top .am-popover-caret{border-top:8px solid #333;border-bottom:none}.lte8 .am-popover-left .am-popover-caret{right:-8px;margin-top:-6px;border-left:8px solid #333;border-right:none}.lte8 .am-popover-right .am-popover-caret{left:-8px;margin-top:-6px;border-right:8px solid #333;border-left:none}.am-accordion-item{margin:0}.am-accordion-title{font-weight:400;cursor:pointer}.am-accordion-item.am-disabled .am-accordion-title{cursor:default;pointer-events:none}.am-accordion-bd{margin:0!important;padding:0!important;border:none!important}.am-accordion-content{margin-top:0;padding:.8rem 1rem 1.2rem;font-size:1.4rem}.am-accordion-default{margin:1rem;border-radius:2px;-webkit-box-shadow:0 0 0 1px rgba(0,0,0,.1);box-shadow:0 0 0 1px rgba(0,0,0,.1)}.am-accordion-default .am-accordion-item{border-top:1px solid rgba(0,0,0,.05)}.am-accordion-default .am-accordion-item:first-child{border-top:none}.am-accordion-default .am-accordion-title{color:rgba(0,0,0,.6);-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;padding:.8rem 1rem}.am-accordion-default .am-accordion-title:before{content:"\f0da";display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);-webkit-transition:-webkit-transform .2s ease;transition:-webkit-transform .2s ease;transition:transform .2s ease;transition:transform .2s ease,-webkit-transform .2s ease;-webkit-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0);margin-right:5px}.am-accordion-default .am-accordion-title:hover{color:#0e90d2}.am-accordion-default .am-accordion-content{color:#666}.am-accordion-default .am-active .am-accordion-title{background-color:#eee;color:#0e90d2}.am-accordion-default .am-active .am-accordion-title:before{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.am-accordion-basic{margin:1rem}.am-accordion-basic .am-accordion-title{color:#333;-webkit-transition:background-color .2s ease-out;transition:background-color .2s ease-out;padding:.8rem 0 0}.am-accordion-basic .am-accordion-title:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f0da";-webkit-transition:-webkit-transform .2s ease;transition:-webkit-transform .2s ease;transition:transform .2s ease;transition:transform .2s ease,-webkit-transform .2s ease;-webkit-transform:rotate(0);-ms-transform:rotate(0);transform:rotate(0);margin-right:.5rem}.am-accordion-basic .am-accordion-content{color:#666}.am-accordion-basic .am-active .am-accordion-title{color:#0e90d2}.am-accordion-basic .am-active .am-accordion-title:before{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.am-accordion-gapped{margin:.5rem 1rem}.am-accordion-gapped .am-accordion-item{border:1px solid #dedede;border-bottom:none;margin:.5rem 0}.am-accordion-gapped .am-accordion-item.am-active{border-bottom:1px solid #dedede}.am-accordion-gapped .am-accordion-title{color:rgba(0,0,0,.6);-webkit-transition:background-color .15s ease-out;transition:background-color .15s ease-out;border-bottom:1px solid #dedede;padding:.8rem 2rem .8rem 1rem;position:relative}.am-accordion-gapped .am-accordion-title:after{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f105";-webkit-transition:-webkit-transform .2s linear;transition:-webkit-transform .2s linear;transition:transform .2s linear;transition:transform .2s linear,-webkit-transform .2s linear;position:absolute;right:10px;top:50%;margin-top:-.8rem}.am-accordion-gapped .am-accordion-title:hover{color:rgba(0,0,0,.8)}.am-accordion-gapped .am-accordion-content{color:#666}.am-accordion-gapped .am-active .am-accordion-title{background-color:#f5f5f5;color:rgba(0,0,0,.8)}.am-accordion-gapped .am-active .am-accordion-title:after{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.am-divider{height:0;margin:1.5rem auto;overflow:hidden;clear:both}.am-divider-default{border-top:1px solid #ddd}.am-divider-dotted{border-top:1px dotted #ccc}.am-divider-dashed{border-top:1px dashed #ccc}.am-figure-zoomable{position:relative;cursor:pointer}.am-figure-zoomable:after{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f00e";position:absolute;top:1rem;right:1rem;color:#999;font-size:1.6rem;-webkit-transition:all .2s;transition:all .2s;pointer-events:none}.am-figure-zoomable:hover:after{color:#eee}.am-figure-default{margin:10px}.am-figure-default img{display:block;max-width:100%;height:auto;padding:2px;border:1px solid #eee;margin:10px auto}.am-figure-default figcaption{text-align:center;font-size:1.4rem;margin-bottom:15px;color:#333}.am-footer{text-align:center;padding:1em 0;font-size:1.6rem}.am-footer .am-switch-mode-ysp{cursor:pointer}.am-footer .am-footer-text{margin-top:10px;font-size:14px}.am-footer .am-footer-text-left{text-align:left;padding-left:10px}.am-modal-footer-hd{padding-bottom:10px}.am-footer-default{background-color:#fff}.am-footer-default a{color:#555}.am-footer-default .am-footer-switch{margin-bottom:10px;font-weight:700}.am-footer-default .am-footer-ysp{color:#555;cursor:pointer}.am-footer-default .am-footer-divider{color:#ccc}.am-footer-default .am-footer-desktop{color:#0e90d2}.am-footer-default .am-footer-miscs{color:#999;font-size:13px}.am-footer-default .am-footer-miscs p{margin:5px 0}@media only screen and (min-width:641px){.am-footer-default .am-footer-miscs p{display:inline-block;margin:5px}}.am-gallery{padding:5px 5px 0 5px;list-style:none}.am-gallery h3{margin:0}[data-am-gallery*=pureview] img{cursor:pointer}.am-gallery-default>li{padding:5px}.am-gallery-default .am-gallery-item img{width:100%;height:auto}.am-gallery-default .am-gallery-title{margin-top:10px;font-weight:400;font-size:1.4rem;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;color:#555}.am-gallery-default .am-gallery-desc{color:#999;font-size:1.2rem}.am-gallery-overlay>li{padding:5px}.am-gallery-overlay .am-gallery-item{position:relative}.am-gallery-overlay .am-gallery-item img{width:100%;height:auto}.am-gallery-overlay .am-gallery-title{font-weight:400;font-size:1.4rem;color:#FFF;position:absolute;bottom:0;width:100%;background-color:rgba(0,0,0,.5);text-indent:5px;height:30px;line-height:30px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-gallery-overlay .am-gallery-desc{display:none}.am-gallery-bordered>li{padding:5px}.am-gallery-bordered .am-gallery-item{-webkit-box-shadow:0 0 3px rgba(0,0,0,.35);box-shadow:0 0 3px rgba(0,0,0,.35);padding:5px}.am-gallery-bordered .am-gallery-item img{width:100%;height:auto}.am-gallery-bordered .am-gallery-title{margin-top:10px;font-weight:400;font-size:1.4rem;color:#555;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-gallery-bordered .am-gallery-desc{color:#999;font-size:1.2rem}.am-gallery-imgbordered>li{padding:5px}.am-gallery-imgbordered .am-gallery-item img{width:100%;height:auto;border:3px solid #FFF;-webkit-box-shadow:0 0 3px rgba(0,0,0,.35);box-shadow:0 0 3px rgba(0,0,0,.35)}.am-gallery-imgbordered .am-gallery-title{margin-top:10px;font-weight:400;font-size:1.4rem;color:#555;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-gallery-imgbordered .am-gallery-desc{color:#999;font-size:1.2rem}.am-gotop a{display:inline-block;text-decoration:none}.am-gotop-default{text-align:center;margin:10px 0}.am-gotop-default a{background-color:#0e90d2;padding:.5em 1.5em;border-radius:0;color:#fff}.am-gotop-default a img{display:none}.am-gotop-fixed{position:fixed;right:10px;bottom:10px;z-index:1010;opacity:0;width:32px;min-height:32px;overflow:hidden;border-radius:0;text-align:center}.am-gotop-fixed.am-active{opacity:.9}.am-gotop-fixed.am-active:hover{opacity:1}.am-gotop-fixed a{display:block}.am-gotop-fixed .am-gotop-title{display:none}.am-gotop-fixed .am-gotop-icon-custom{display:inline-block;max-width:30px;vertical-align:middle}.am-gotop-fixed .am-gotop-icon{width:100%;line-height:32px;background-color:#555;vertical-align:middle;color:#ddd}.am-gotop-fixed .am-gotop-icon:hover{color:#fff}.am-with-fixed-navbar .am-gotop-fixed{bottom:60px}.am-header{position:relative;width:100%;height:49px;line-height:49px;padding:0 10px}.am-header h1{margin-top:0;margin-bottom:0}.am-header .am-header-title{margin:0 30%;font-size:2rem;font-weight:400;text-align:center;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-header .am-header-title img{margin-top:12px;height:25px;vertical-align:top}.am-header .am-header-nav{position:absolute;top:0}.am-header .am-header-nav img{height:16px;width:auto;vertical-align:middle}.am-header .am-header-left{left:10px}.am-header .am-header-right{right:10px}.am-header-fixed{position:fixed;top:0;left:0;right:0;width:100%;z-index:1010}.am-with-fixed-header{padding-top:49px}.am-header-default{background-color:#0e90d2}.am-header-default .am-header-title{color:#fff}.am-header-default .am-header-title a{color:#fff}.am-header-default .am-header-icon{font-size:20px}.am-header-default .am-header-nav{color:#eee}.am-header-default .am-header-nav>a{display:inline-block;min-width:36px;text-align:center;color:#eee}.am-header-default .am-header-nav>a+a{margin-left:5px}.am-header-default .am-header-nav .am-btn{margin-top:9px;height:31px;padding:0 .5em;line-height:30px;font-size:14px;vertical-align:top}.am-header-default .am-header-nav .am-btn .am-header-icon{font-size:inherit}.am-header-default .am-header-nav .am-btn-default{color:#999}.am-header-default .am-header-nav-title,.am-header-default .am-header-nav-title+.am-header-icon{font-size:14px}.am-intro{position:relative}.am-intro img{max-width:100%}.am-intro-hd{position:relative;height:45px;line-height:45px}.am-intro-title{font-size:18px;margin:0;font-weight:700}.am-intro-more-top{position:absolute;right:10px;top:0;font-size:1.4rem}.am-intro-bd{padding-top:15px;padding-bottom:15px;font-size:1.4rem}.am-intro-bd p:last-child{margin-bottom:0}.am-intro-more-bottom{clear:both;text-align:center}.am-intro-more-bottom .am-btn{font-size:14px}.am-intro-default .am-intro-hd{background-color:#0e90d2;color:#fff;padding:0 10px}.am-intro-default .am-intro-hd a{color:#eee}.am-intro-default .am-intro-right{padding-left:0}.am-list-news-hd{padding-top:1.2rem;padding-bottom:.8rem}.am-list-news-hd a{display:block}.am-list-news-hd h2{font-size:1.6rem;float:left;margin:0;height:2rem;line-height:2rem}.am-list-news-hd h3{margin:0}.am-list-news-hd .am-list-news-more{font-size:1.3rem;height:2rem;line-height:2rem}.am-list .am-list-item-dated a{padding-right:80px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-list .am-list-item-dated a::after{display:none}.am-list .am-list-item-desced a,.am-list .am-list-item-thumbed a{padding-right:0}.am-list-news .am-list-item-hd{margin:0}.am-list-date{position:absolute;right:5px;font-size:1.3rem;top:1.3rem}.am-list-item-desced{padding-bottom:1rem}.am-list-item-desced>a{padding:1rem 0}.am-list-item-desced .am-list-date{position:static}.am-list-item-thumbed{padding-top:1em}.am-list-news-ft{text-align:center}.am-list-news .am-titlebar{margin-left:0;margin-right:0}.am-list-news .am-titlebar~.am-list-news-bd .am-list>li:first-child{border-top:none}.am-list-news-default{margin:10px}.am-list-news-default .am-g{margin-left:auto;margin-right:auto}.am-list-news-default .am-list-item-hd{font-weight:400}.am-list-news-default .am-list-date{color:#999}.am-list-news-default .am-list>li{border-color:#dedede}.am-list-news-default .am-list .am-list-item-desced{padding-top:1rem;padding-bottom:1rem}.am-list-news-default .am-list .am-list-item-desced>a{padding:0}.am-list-news-default .am-list .am-list-item-desced .am-list-item-text{margin-top:.5rem;color:#757575}.am-list-news-default .am-list .am-list-item-text{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;line-height:1.3em;-webkit-line-clamp:2;max-height:2.6em}.am-list-news-default .am-list .am-list-item-thumb-top .am-list-thumb{padding:0;margin-bottom:.8rem}.am-list-news-default .am-list .am-list-item-thumb-top .am-list-main{padding:0}.am-list-news-default .am-list .am-list-item-thumb-left .am-list-thumb{padding-left:0}.am-list-news-default .am-list .am-list-item-desced .am-list-main{padding:0}.am-list-news-default .am-list .am-list-item-thumb-right .am-list-thumb{padding-right:0}.am-list-news-default .am-list .am-list-item-thumb-bottom-left .am-list-item-hd{clear:both;padding-bottom:.5rem}.am-list-news-default .am-list .am-list-item-thumb-bottom-left .am-list-thumb{padding-left:0}.am-list-news-default .am-list .am-list-item-thumb-bottom-right .am-list-item-hd{clear:both;padding-bottom:.5rem}.am-list-news-default .am-list .am-list-item-thumb-bottom-right .am-list-thumb{padding-right:0}.am-list-news-default .am-list .am-list-thumb img{width:100%;display:block}@media only screen and (max-width:640px){.am-list-news-default .am-list-item-thumb-left .am-list-thumb,.am-list-news-default .am-list-item-thumb-right .am-list-thumb{max-height:80px;overflow:hidden}.am-list-news-default .am-list-item-thumb-bottom-left .am-list-item-text,.am-list-news-default .am-list-item-thumb-bottom-right .am-list-item-text{-webkit-line-clamp:3;max-height:3.9em}.am-list-news-default .am-list-item-thumb-bottom-left .am-list-thumb,.am-list-news-default .am-list-item-thumb-bottom-right .am-list-thumb{max-height:60px;overflow:hidden}}.am-map{width:100%;height:300px}.am-map-default #bd-map{width:100%;height:100%;overflow:hidden;margin:0;font-size:14px;line-height:1.4!important}.am-map-default .BMap_bubble_title{font-weight:700}.am-map-default #BMap_mask{width:100%}.am-mechat{margin:1rem}.am-mechat .section-cbox-wap .cbox-post-wap .post-action-wap .action-function-wap .function-list-wap .list-upload-wap .upload-mutual-wap{-webkit-box-sizing:content-box;box-sizing:content-box}.am-menu{position:relative;padding:0;margin:0}.am-menu ul{padding:0;margin:0}.am-menu li{list-style:none}.am-menu a:after,.am-menu a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.am-menu-sub{z-index:1050}.am-menu-toggle{display:none;z-index:1015}.am-menu-toggle img{display:inline-block;height:16px;width:auto;vertical-align:middle}.am-menu-nav a{display:block;padding:.8rem 0;-webkit-transition:all .45s;transition:all .45s}.am-menu-default .am-menu-nav{padding-top:8px;padding-bottom:8px}.am-menu-default .am-menu-nav a{text-align:center;height:36px;line-height:36px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding:0;color:#0e90d2}.am-menu-default .am-menu-nav>.am-parent>a{position:relative;-webkit-transition:.15s;transition:.15s}.am-menu-default .am-menu-nav>.am-parent>a:after{content:"\f107";margin-left:5px;-webkit-transition:.15s;transition:.15s}.am-menu-default .am-menu-nav>.am-parent>a:before{position:absolute;top:100%;margin-top:-16px;left:50%;margin-left:-12px;content:"\f0d8";display:none;color:#f1f1f1;font-size:24px}.am-menu-default .am-menu-nav>.am-parent.am-open>a{color:#095f8a}.am-menu-default .am-menu-nav>.am-parent.am-open>a:before{display:block}.am-menu-default .am-menu-nav>.am-parent.am-open>a:after{-webkit-transform:rotate(-180deg);-ms-transform:rotate(-180deg);transform:rotate(-180deg)}.am-menu-default .am-menu-sub{position:absolute;left:5px;right:5px;background-color:#f1f1f1;border-radius:0;padding-top:8px;padding-bottom:8px}.am-menu-default .am-menu-sub>li>a{color:#555}@media only screen and (min-width:641px){.am-menu-default .am-menu-nav li{width:auto;float:left;clear:none;display:inline}.am-menu-default .am-menu-nav a{padding-left:1.5rem;padding-right:.5rem}}.am-menu-dropdown1{position:relative}.am-menu-dropdown1 .am-menu-toggle{position:absolute;right:5px;top:-47px;display:block;width:44px;height:44px;line-height:44px;text-align:center;color:#fff}.am-menu-dropdown1 a{-webkit-transition:all .4s;transition:all .4s;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-menu-dropdown1 .am-menu-nav{position:absolute;left:0;right:0;z-index:1050}.am-menu-dropdown1 .am-menu-nav a{padding:.8rem}.am-menu-dropdown1 .am-menu-nav>li{width:100%}.am-menu-dropdown1 .am-menu-nav>li.am-parent>a{position:relative}.am-menu-dropdown1 .am-menu-nav>li.am-parent>a::before{content:"\f067";position:absolute;right:1rem;top:1.4rem}.am-menu-dropdown1 .am-menu-nav>li.am-parent.am-open>a{background-color:#0c80ba;border-bottom:none;color:#fff}.am-menu-dropdown1 .am-menu-nav>li.am-parent.am-open>a:before{content:"\f068"}.am-menu-dropdown1 .am-menu-nav>li.am-parent.am-open>a:after{content:"";display:inline-block;width:0;height:0;vertical-align:middle;border-top:8px solid #0c80ba;border-right:8px solid transparent;border-left:8px solid transparent;border-bottom:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);position:absolute;top:100%;left:50%;margin-left:-4px}.am-menu-dropdown1 .am-menu-nav>li>a{border-bottom:1px solid #0b76ac;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.05);background-color:#0e90d2;color:#fff;height:49px;line-height:49px;padding:0;text-indent:10px}.am-menu-dropdown1 .am-menu-sub{background-color:#fff}.am-menu-dropdown1 .am-menu-sub a{color:#555;height:44px;line-height:44px;text-indent:5px;padding:0}.am-menu-dropdown1 .am-menu-sub a:before{content:"\f105";color:#aaa;font-size:16px;margin-right:5px}.am-menu-dropdown2 .am-menu-toggle{position:absolute;right:5px;top:-47px;display:block;width:44px;height:44px;line-height:44px;text-align:center;color:#fff}.am-menu-dropdown2 .am-menu-nav{position:absolute;left:0;right:0;background-color:#f5f5f5;-webkit-box-shadow:0 0 5px rgba(0,0,0,.2);box-shadow:0 0 5px rgba(0,0,0,.2);z-index:1050;padding-top:8px;padding-bottom:8px}.am-menu-dropdown2 .am-menu-nav a{height:38px;line-height:38px;padding:0;text-align:center}.am-menu-dropdown2 .am-menu-nav>li>a{color:#333}.am-menu-dropdown2 .am-menu-nav>li.am-parent>a{position:relative}.am-menu-dropdown2 .am-menu-nav>li.am-parent>a:after{content:"\f107";margin-left:5px;-webkit-transition:-webkit-transform .2s;transition:-webkit-transform .2s;transition:transform .2s;transition:transform .2s,-webkit-transform .2s}.am-menu-dropdown2 .am-menu-nav>li.am-parent.am-open>a{position:relative}.am-menu-dropdown2 .am-menu-nav>li.am-parent.am-open>a:after{color:#0e90d2;-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.am-menu-dropdown2 .am-menu-nav>li.am-parent.am-open>a:before{position:absolute;top:100%;margin-top:-16px;left:50%;margin-left:-12px;font-size:24px;content:"\f0d8";color:rgba(0,0,0,.2)}.am-menu-dropdown2 .am-menu-sub{position:absolute;left:5px;right:5px;padding:8px 0;border-radius:2px;-webkit-box-shadow:0 0 3px rgba(0,0,0,.15);box-shadow:0 0 3px rgba(0,0,0,.15);background-color:#fff;z-index:1055}.am-menu-dropdown2 .am-menu-sub a{padding:0;height:35px;color:#555;line-height:35px}@media only screen and (min-width:641px){.am-menu-dropdown2 .am-menu-toggle{display:none!important}.am-menu-dropdown2 .am-menu-nav{position:static;display:block}.am-menu-dropdown2 .am-menu-nav>li{float:none;width:auto;display:inline-block}.am-menu-dropdown2 .am-menu-nav>li a{padding-left:1.5rem;padding-right:1.5rem}.am-menu-dropdown2 .am-menu-sub{left:auto;right:auto}.am-menu-dropdown2 .am-menu-sub>li{float:none;width:auto}.am-menu-dropdown2 .am-menu-sub a{padding-left:2rem;padding-right:2rem}}.am-menu-slide1 .am-menu-toggle{position:absolute;right:5px;top:-47px;display:block;width:44px;height:44px;line-height:44px;text-align:center;color:#fff}.am-menu-slide1 .am-menu-nav{background-color:#f5f5f5;padding-top:8px;padding-bottom:8px}.am-menu-slide1 .am-menu-nav.am-in:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f0d8";font-size:24px;color:#f5f5f5;position:absolute;right:16px;top:-16px}.am-menu-slide1 .am-menu-nav a{line-height:38px;height:38px;display:block;padding:0;text-align:center}.am-menu-slide1 .am-menu-nav>li>a{color:#333;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-menu-slide1 .am-menu-nav>.am-parent>a{position:relative;-webkit-transition:.15s;transition:.15s}.am-menu-slide1 .am-menu-nav>.am-parent>a:after{content:"\f107";margin-left:5px;-webkit-transition:.15s;transition:.15s}.am-menu-slide1 .am-menu-nav>.am-parent>a:before{position:absolute;top:100%;margin-top:-16px;left:50%;margin-left:-12px;content:"\f0d8";display:none;color:#0e90d2;font-size:24px}.am-menu-slide1 .am-menu-nav>.am-parent.am-open>a{color:#0e90d2}.am-menu-slide1 .am-menu-nav>.am-parent.am-open>a:before{display:block}.am-menu-slide1 .am-menu-nav>.am-parent.am-open>a:after{-webkit-transform:rotate(-180deg);-ms-transform:rotate(-180deg);transform:rotate(-180deg)}.am-menu-slide1 .am-menu-sub{position:absolute;left:5px;right:5px;background-color:#0e90d2;border-radius:0;padding-top:8px;padding-bottom:8px}.am-menu-slide1 .am-menu-sub>li>a{color:#fff}@media only screen and (min-width:641px){.am-menu-slide1 .am-menu-toggle{display:none!important}.am-menu-slide1 .am-menu-nav{background-color:#f5f5f5;display:block}.am-menu-slide1 .am-menu-nav.am-in:before{display:none}.am-menu-slide1 .am-menu-nav li{width:auto;clear:none}.am-menu-slide1 .am-menu-nav li a{padding-left:1.5rem;padding-right:1.5rem}}.am-menu-offcanvas1 .am-menu-toggle{position:absolute;right:5px;top:-47px;display:block;width:44px;height:44px;line-height:44px;text-align:center;color:#fff}.am-menu-offcanvas1 .am-menu-nav{border-bottom:1px solid rgba(0,0,0,.3);-webkit-box-shadow:0 1px 0 rgba(255,255,255,.05);box-shadow:0 1px 0 rgba(255,255,255,.05)}.am-menu-offcanvas1 .am-menu-nav>li>a{height:44px;line-height:44px;text-indent:15px;padding:0;position:relative;color:#ccc;border-top:1px solid rgba(0,0,0,.3);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.05);text-shadow:0 1px 0 rgba(0,0,0,.5)}.am-menu-offcanvas1 .am-menu-nav>.am-open>a,.am-menu-offcanvas1 .am-menu-nav>li>a:focus,.am-menu-offcanvas1 .am-menu-nav>li>a:hover{background-color:#474747;color:#fff;outline:0}.am-menu-offcanvas1 .am-menu-nav>.am-active>a{background-color:#1a1a1a;color:#fff}.am-menu-offcanvas1 .am-menu-nav>.am-parent>a{-webkit-transition:all .3s;transition:all .3s}.am-menu-offcanvas1 .am-menu-nav>.am-parent>a:after{content:"\f104";position:absolute;right:1.5rem;top:1.3rem}.am-menu-offcanvas1 .am-menu-nav>.am-parent.am-open>a:after{content:"\f107"}.am-menu-offcanvas1 .am-menu-sub{border-top:1px solid rgba(0,0,0,.3);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.05);padding:5px 0 5px 15px;background-color:#1a1a1a;font-size:1.4rem}.am-menu-offcanvas1 .am-menu-sub a{color:#eee}.am-menu-offcanvas1 .am-menu-sub a:hover{color:#fff}.am-menu-offcanvas1 .am-nav-divider{border-top:1px solid #1a1a1a}.am-menu-offcanvas2 .am-menu-toggle{position:absolute;right:5px;top:-47px;display:block;width:44px;height:44px;line-height:44px;text-align:center;color:#fff}.am-menu-offcanvas2 .am-menu-nav{padding:10px 5px}.am-menu-offcanvas2 .am-menu-nav>li{padding:5px}.am-menu-offcanvas2 .am-menu-nav>li>a{-webkit-transition:all .3s;transition:all .3s;background-color:#404040;color:#ccc;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;border:1px solid rgba(0,0,0,.3);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.05);text-shadow:0 1px 0 rgba(0,0,0,.5);height:44px;line-height:44px;padding:0;text-align:center}.am-menu-offcanvas2 .am-menu-nav>li>a:focus,.am-menu-offcanvas2 .am-menu-nav>li>a:hover{background-color:#262626;color:#fff;outline:0}.am-menu-offcanvas2 .am-menu-nav>.am-active>a{background-color:#262626;color:#fff}.am-menu-stack .am-menu-nav{border-bottom:1px solid #dedede;-webkit-box-shadow:0 1px 0 rgba(255,255,255,.05);box-shadow:0 1px 0 rgba(255,255,255,.05)}.am-menu-stack .am-menu-nav>.am-parent>a{-webkit-transition:all .3s;transition:all .3s}.am-menu-stack .am-menu-nav>.am-parent>a:after{content:"\f105";position:absolute;right:1.5rem;top:1.3rem;-webkit-transition:all .15s;transition:all .15s}.am-menu-stack .am-menu-nav>.am-parent.am-open>a:after{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.am-menu-stack .am-menu-nav>li>a{position:relative;color:#333;background-color:#f5f5f5;border-top:1px solid #dedede;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.05);height:49px;line-height:49px;text-indent:10px;padding:0}.am-menu-stack .am-menu-nav>.am-open>a,.am-menu-stack .am-menu-nav>li>a:focus,.am-menu-stack .am-menu-nav>li>a:hover{background-color:#e5e5e5;color:#222;outline:0}.am-menu-stack .am-menu-sub{padding:0;font-size:1.4rem;border-top:1px solid #dedede}.am-menu-stack .am-menu-sub a{border-bottom:1px solid #dedede;padding-left:2rem;color:#444}.am-menu-stack .am-menu-sub a:hover{color:#333}.am-menu-stack .am-menu-sub li:last-child a{border-bottom:none}.am-menu-stack .am-menu-sub>li>a{height:44px;line-height:44px;text-indent:15px;padding:0}@media only screen and (min-width:641px){.am-menu-stack .am-menu-nav{background-color:#f5f5f5}.am-menu-stack .am-menu-nav>li{float:left;width:auto;clear:none!important;display:inline-block}.am-menu-stack .am-menu-nav>li a{padding-left:1.5rem;padding-right:1.5rem}.am-menu-stack .am-menu-nav>li.am-parent>a:after{position:static;content:"\f107"}.am-menu-stack .am-menu-nav>li.am-parent.am-open a{border-bottom:none}.am-menu-stack .am-menu-nav>li.am-parent.am-open a:after{-webkit-transform:rotateX(-180deg);transform:rotateX(-180deg)}.am-menu-stack .am-menu-nav>li.am-parent.am-open .am-menu-sub{background-color:#e5e5e5}.am-menu-stack .am-menu-sub{position:absolute;left:0;right:0;background-color:#ddd;border-top:none}.am-menu-stack .am-menu-sub li{width:auto;float:left;clear:none}}.am-navbar{position:fixed;left:0;bottom:0;width:100%;height:49px;line-height:49px;z-index:1010}.am-navbar ul{padding-left:0;margin:0;list-style:none;width:100%}.am-navbar .am-navbar-nav{padding-left:8px;padding-right:8px;text-align:center;overflow:hidden}.am-navbar .am-navbar-nav li{display:table-cell;width:1%;float:none}.am-navbar-nav{position:relative;z-index:1015}.am-navbar-nav a{display:inline-block;width:100%;height:49px;line-height:20px}.am-navbar-nav a img{display:block;vertical-align:middle;height:24px;width:24px;margin:4px auto 0}.am-navbar-nav a [class*=am-icon]{width:24px;height:24px;margin:4px auto 0;display:block;line-height:24px}.am-navbar-nav a [class*=am-icon]:before{font-size:22px;vertical-align:middle}.am-navbar-nav a .am-navbar-label{padding-top:2px;line-height:1;font-size:12px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-navbar-more [class*=am-icon-]{-webkit-transition:.15s;transition:.15s}.am-navbar-more.am-active [class*=am-icon-]{-webkit-transform:rotateX(-180deg);transform:rotateX(-180deg)}.am-navbar-actions{position:absolute;bottom:49px;right:0;left:0;z-index:1009;opacity:0;-webkit-transition:.3s;transition:.3s;-webkit-transform:translate(0,100%);-ms-transform:translate(0,100%);transform:translate(0,100%)}.am-navbar-actions.am-active{opacity:1;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0)}.am-navbar-actions li{line-height:42px;position:relative}.am-navbar-actions li a{display:block;width:100%;height:40px;-webkit-box-shadow:inset 0 1px rgba(220,220,220,.25);box-shadow:inset 0 1px rgba(220,220,220,.25);padding-left:20px;padding-right:36px}.am-navbar-actions li a :after{font-family:FontAwesome,sans-serif;content:"\f105";display:inline-block;position:absolute;top:0;right:20px}.am-navbar-actions li a img{vertical-align:middle;height:20px;width:20px;display:inline}#am-navbar-qrcode{width:220px;height:220px;margin-left:-110px}#am-navbar-qrcode .am-modal-bd{padding:10px}#am-navbar-qrcode canvas{display:block;width:200px;height:200px}.am-with-fixed-navbar{padding-bottom:54px}.am-navbar-default a{color:#fff}.am-navbar-default .am-navbar-nav{background-color:#0e90d2}.am-navbar-default .am-navbar-actions{background-color:#0d86c4}.am-navbar-default .am-navbar-actions a{border-bottom:1px solid #0b6fa2}.am-pagination{position:relative}.am-pagination-default{margin-left:10px;margin-right:10px;font-size:1.6rem}.am-pagination-default .am-pagination-next,.am-pagination-default .am-pagination-prev{float:none}.am-pagination-select{margin-left:10px;margin-right:10px;font-size:1.6rem}.am-pagination-select>li>a{line-height:36px;background-color:#eee;padding:0 15px;border:0;color:#555}.am-pagination-select .am-pagination-select{position:absolute;top:0;left:50%;margin-left:-35px;width:70px;height:36px;text-align:center;border-radius:0}.am-pagination-select .am-pagination-select select{display:block;border:0;line-height:36px;width:70px;height:36px;border-radius:0;color:#555;background-color:#eee;-webkit-appearance:none;-moz-appearance:none;appearance:none;padding-left:18px}.am-paragraph p{margin:10px 0}.am-paragraph img{max-width:100%}.am-paragraph h1,.am-paragraph h2,.am-paragraph h3,.am-paragraph h4,.am-paragraph h5,.am-paragraph h6{color:#222}.am-paragraph table{max-width:none}.am-paragraph-table-container{overflow:hidden;background:#eee;max-width:none}.am-paragraph-table-container table{width:100%;max-width:none}.am-paragraph-table-container table th{background:#bce5fb;height:40px;border:1px solid #999;text-align:center}.am-paragraph-table-container table td{border:1px solid #999;text-align:center;vertical-align:middle;background:#fff}.am-paragraph-table-container table td p{text-indent:0;font-size:1.4rem}.am-paragraph-table-container table td a{font-size:1.4rem}.am-paragraph-default{margin:0 10px;color:#333;background-color:transparent}.am-paragraph-default p{font-size:1.4rem}.am-paragraph-default img{max-width:98%;display:block;margin:5px auto;border:1px solid #eee;padding:2px}.am-paragraph-default a{color:#0e90d2}.am-slider-a1{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-a1 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-a1 .am-viewport{max-height:300px}.am-slider-a1 .am-control-nav{width:100%;position:absolute;bottom:5px;text-align:center;line-height:0}.am-slider-a1 .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-a1 .am-control-nav li a{width:8px;height:8px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px;border-radius:50%;-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,.3);box-shadow:inset 0 0 3px rgba(0,0,0,.3)}.am-slider-a1 .am-control-nav li a:hover{background-color:rgba(0,0,0,.7)}.am-slider-a1 .am-control-nav li a.am-active{background-color:#0e90d2;cursor:default}.am-slider-a1 .am-direction-nav,.am-slider-a1 .am-pauseplay{display:none}.am-slider-a2{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-a2 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-a2 .am-viewport{max-height:300px}.am-slider-a2 .am-control-nav{width:100%;position:absolute;bottom:5px;text-align:center;line-height:0}.am-slider-a2 .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-a2 .am-control-nav li a{width:8px;height:8px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px;-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,.3);box-shadow:inset 0 0 3px rgba(0,0,0,.3)}.am-slider-a2 .am-control-nav li a:hover{background-color:rgba(0,0,0,.7)}.am-slider-a2 .am-control-nav li a.am-active{background:#0e93d7;cursor:default}.am-slider-a2 .am-direction-nav,.am-slider-a2 .am-pauseplay{display:none}.am-slider-a3{margin-bottom:20px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-a3 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-a3 .am-viewport{max-height:300px}.am-slider-a3 .am-control-nav{width:100%;position:absolute;bottom:-20px;text-align:center;height:20px;background-color:#000;padding-top:5px;line-height:0}.am-slider-a3 .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-a3 .am-control-nav li a{width:8px;height:8px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px;border-radius:50%;-webkit-box-shadow:inset 0 0 3px rgba(200,200,200,.3);box-shadow:inset 0 0 3px rgba(200,200,200,.3)}.am-slider-a3 .am-control-nav li a:hover{background-color:rgba(0,0,0,.7)}.am-slider-a3 .am-control-nav li a.am-active{background:#0e90d2;cursor:default}.am-slider-a3 .am-direction-nav,.am-slider-a3 .am-pauseplay{display:none}.am-slider-a4{margin-bottom:30px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-a4 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-a4 .am-viewport{max-height:300px}.am-slider-a4 .am-control-nav{width:100%;position:absolute;bottom:-15px;text-align:center;line-height:0}.am-slider-a4 .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-a4 .am-control-nav li a{width:8px;height:8px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px;border-radius:50%;-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,.3);box-shadow:inset 0 0 3px rgba(0,0,0,.3)}.am-slider-a4 .am-control-nav li a:hover{background-color:rgba(0,0,0,.7)}.am-slider-a4 .am-control-nav li a.am-active{background-color:#0e90d2;cursor:default}.am-slider-a4 .am-direction-nav,.am-slider-a4 .am-pauseplay{display:none}.am-slider-a5{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-a5 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-a5 .am-viewport{max-height:300px}.am-slider-a5 .am-control-nav{width:100%;position:absolute;text-align:center;height:6px;display:table;bottom:0;font-size:0;line-height:0}.am-slider-a5 .am-control-nav li{display:table-cell}.am-slider-a5 .am-control-nav li a{width:100%;height:6px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px}.am-slider-a5 .am-control-nav li a:hover{background-color:rgba(0,0,0,.7)}.am-slider-a5 .am-control-nav li a.am-active{background-color:#0e90d2;cursor:default}.am-slider-a5 .am-direction-nav,.am-slider-a5 .am-pauseplay{display:none}.am-slider-b1{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-b1 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-b1 .am-viewport{max-height:300px}.am-slider-b1 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;padding:8px 0;margin:-20px 0 0;position:absolute;top:50%;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;color:#fff;text-shadow:1px 1px 0 rgba(255,255,255,.3);background-color:rgba(0,0,0,.5);font-size:0;text-align:center;-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-b1 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:24px}.am-slider-b1 .am-direction-nav a.am-prev{left:0;padding-right:5px;border-bottom-right-radius:5px;border-top-right-radius:5px}.am-slider-b1 .am-direction-nav a.am-next{right:0;padding-left:5px;border-bottom-left-radius:5px;border-top-left-radius:5px}.am-slider-b1 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-b1 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-b1:hover .am-prev{opacity:.7}.am-slider-b1:hover .am-prev:hover{opacity:1}.am-slider-b1:hover .am-next{opacity:.7}.am-slider-b1:hover .am-next:hover{opacity:1}.am-slider-b1 .am-control-nav,.am-slider-b1 .am-pauseplay{display:none}.am-slider-b2{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-b2 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-b2 .am-viewport{max-height:300px}.am-slider-b2 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;padding:4px;margin:-16px 0 0;position:absolute;top:50%;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;color:#fff;text-shadow:1px 1px 0 rgba(255,255,255,.3);background-color:rgba(0,0,0,.5);font-size:0;text-align:center;border-radius:50%;-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-b2 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:16px;line-height:24px}.am-slider-b2 .am-direction-nav a.am-prev{left:5px}.am-slider-b2 .am-direction-nav a.am-next{right:5px}.am-slider-b2 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-b2 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-b2:hover .am-prev{opacity:.7}.am-slider-b2:hover .am-prev:hover{opacity:1}.am-slider-b2:hover .am-next{opacity:.7}.am-slider-b2:hover .am-next:hover{opacity:1}.am-slider-b2 .am-control-nav,.am-slider-b2 .am-pauseplay{display:none}.am-slider-b3{margin:15px 30px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-b3 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-b3 .am-viewport{max-height:300px}.am-slider-b3 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;padding:4px;margin:-16px 0 0;position:absolute;top:50%;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;color:#333;text-shadow:1px 1px 0 rgba(255,255,255,.3);font-size:0;-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-b3 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:24px}.am-slider-b3 .am-direction-nav a.am-prev{left:-25px}.am-slider-b3 .am-direction-nav a.am-next{right:-25px;text-align:right}.am-slider-b3 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-b3 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-b3:hover .am-prev{opacity:.7}.am-slider-b3:hover .am-prev:hover{opacity:1}.am-slider-b3:hover .am-next{opacity:.7}.am-slider-b3:hover .am-next:hover{opacity:1}.am-slider-b3 .am-control-nav,.am-slider-b3 .am-pauseplay{display:none}.am-slider-b4{margin:15px 20px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-b4 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-b4 .am-viewport{max-height:300px}.am-slider-b4 .am-direction-nav a{position:absolute;top:50%;z-index:10;display:block;-webkit-box-sizing:content-box;box-sizing:content-box;width:24px;height:24px;margin:-16px 0 0;padding:4px;overflow:hidden;opacity:.45;background-color:rgba(0,0,0,.8);cursor:pointer;text-shadow:1px 1px 0 rgba(255,255,255,.3);font-size:0;border-radius:50%;text-align:center;color:#fff;-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-b4 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:20px;line-height:24px}.am-slider-b4 .am-direction-nav a.am-prev{left:-15px}.am-slider-b4 .am-direction-nav a.am-next{right:-15px}.am-slider-b4 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-b4 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-b4:hover .am-prev{opacity:.7}.am-slider-b4:hover .am-prev:hover{opacity:.9}.am-slider-b4:hover .am-next{opacity:.7}.am-slider-b4:hover .am-next:hover{opacity:.9}.am-slider-b4 .am-control-nav,.am-slider-b4 .am-pauseplay{display:none}.am-slider-c1{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-c1 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-c1 .am-viewport{max-height:300px}.am-slider-c1 .am-control-nav{position:absolute;bottom:0;display:table;width:100%;height:6px;font-size:0;line-height:0;text-align:center}.am-slider-c1 .am-control-nav li{display:table-cell;width:1%}.am-slider-c1 .am-control-nav li a{width:100%;height:6px;display:block;background-color:rgba(0,0,0,.7);cursor:pointer;text-indent:-9999px}.am-slider-c1 .am-control-nav li a:hover{background:rgba(0,0,0,.8)}.am-slider-c1 .am-control-nav li a.am-active{background-color:#0e90d2;cursor:default}.am-slider-c1 .am-slider-desc{background-color:rgba(0,0,0,.6);position:absolute;bottom:6px;padding:8px;width:100%;color:#fff;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-c1 .am-direction-nav,.am-slider-c1 .am-pauseplay{display:none}.am-slider-c2{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-c2 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-c2 .am-viewport{max-height:300px}.am-slider-c2 .am-control-nav{position:absolute;bottom:15px;right:0;height:6px;text-align:center;font-size:0;line-height:0}.am-slider-c2 .am-control-nav li{display:inline-block;margin-right:6px}.am-slider-c2 .am-control-nav li a{width:6px;height:6px;display:block;background-color:rgba(255,255,255,.4);cursor:pointer;text-indent:-9999px}.am-slider-c2 .am-control-nav li a:hover{background:rgba(230,230,230,.4)}.am-slider-c2 .am-control-nav li a.am-active{background-color:#0e90d2;cursor:default}.am-slider-c2 .am-slider-desc{background-color:rgba(0,0,0,.6);position:absolute;bottom:0;padding:8px 60px 8px 8px;width:100%;color:#fff;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-c2 .am-direction-nav,.am-slider-c2 .am-pauseplay{display:none}.am-slider-c3{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-c3 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-c3 .am-viewport{max-height:300px}.am-slider-c3 .am-slider-desc{background-color:rgba(0,0,0,.6);position:absolute;bottom:10px;right:60px;height:30px;left:0;padding-right:5px;color:#fff;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-c3 .am-slider-counter{margin-right:5px;display:inline-block;height:30px;background-color:#0e90d2;width:40px;text-align:center;line-height:30px;color:#eee;font-size:1rem}.am-slider-c3 .am-slider-counter .am-active{font-size:1.8rem;font-weight:700;color:#fff}.am-slider-c3 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;padding:4px 0;margin:-16px 0 0;position:absolute;top:50%;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;color:#fff;text-shadow:1px 1px 0 rgba(255,255,255,.3);background-color:rgba(0,0,0,.5);font-size:0;text-align:center;-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-c3 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:16px;line-height:24px}.am-slider-c3 .am-direction-nav a.am-prev{left:0;padding-right:5px}.am-slider-c3 .am-direction-nav a.am-next{right:0;padding-left:5px}.am-slider-c3 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-c3 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-c3:hover .am-prev{opacity:.7}.am-slider-c3:hover .am-prev:hover{opacity:1}.am-slider-c3:hover .am-next{opacity:.7}.am-slider-c3:hover .am-next:hover{opacity:1}.am-slider-c3 .am-control-nav,.am-slider-c3 .am-pauseplay{display:none}.am-slider-c4{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-c4 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-c4 .am-viewport{max-height:300px}.am-slider-c4 .am-slider-desc{width:100%;background-color:rgba(0,0,0,.6);position:absolute;bottom:0;right:0;left:0;padding:8px 40px;color:#fff;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-c4 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;padding:4px 0;margin:0;position:absolute;bottom:4px;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;text-shadow:1px 1px 0 rgba(255,255,255,.3);font-size:0;text-align:center;color:rgba(0,0,0,.7);-webkit-transition:all .3s ease;transition:all .3s ease}.am-slider-c4 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:24px}.am-slider-c4 .am-direction-nav a.am-prev{left:0;padding-right:5px}.am-slider-c4 .am-direction-nav a.am-next{right:0;padding-left:5px}.am-slider-c4 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-c4 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-c4:hover .am-prev{opacity:.7}.am-slider-c4:hover .am-prev:hover{opacity:1}.am-slider-c4:hover .am-next{opacity:.7}.am-slider-c4:hover .am-next:hover{opacity:1}.am-slider-c4 .am-control-nav,.am-slider-c4 .am-pauseplay{display:none}.am-slider-d1{-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-d1 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-d1 .am-viewport{max-height:300px}.am-slider-d1 .am-slider-desc{padding:8px 35px;width:100%;color:#fff;background-color:#0e90d2}.am-slider-d1 .am-slider-title{font-weight:400;margin-bottom:2px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-d1 .am-slider-more{color:#eee;font-size:1.3rem}.am-slider-d1 .am-direction-nav a{-webkit-box-sizing:content-box;box-sizing:content-box;display:block;width:24px;height:24px;margin:0;position:absolute;bottom:18px;z-index:10;overflow:hidden;opacity:.45;cursor:pointer;text-shadow:1px 1px 0 rgba(255,255,255,.3);font-size:0;text-align:center;border:1px solid rgba(255,255,255,.9);color:rgba(255,255,255,.9);border-radius:50%;-webkit-transition:all 3s ease;transition:all 3s ease}.am-slider-d1 .am-direction-nav a:before{display:inline-block;font:normal normal normal 1.6rem/1 FontAwesome,sans-serif;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);content:"\f053";font-size:16px;line-height:24px}.am-slider-d1 .am-direction-nav a.am-prev{left:5px}.am-slider-d1 .am-direction-nav a.am-next{right:5px}.am-slider-d1 .am-direction-nav a.am-next:before{content:"\f054"}.am-slider-d1 .am-direction-nav .am-disabled{opacity:0!important;cursor:default}.am-slider-d1:hover .am-prev{opacity:.7}.am-slider-d1:hover .am-prev:hover{opacity:1}.am-slider-d1:hover .am-next{opacity:.7}.am-slider-d1:hover .am-next:hover{opacity:1}.am-slider-d1 .am-control-nav,.am-slider-d1 .am-pauseplay{display:none}.am-slider-d2{margin-bottom:20px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-d2 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-d2 .am-viewport{max-height:300px}.am-slider-d2 .am-slider-desc{position:absolute;left:10px;bottom:20px;right:50px;color:#fff}.am-slider-d2 .am-slider-content{background-color:rgba(0,0,0,.7);padding:10px 6px;margin-bottom:10px}.am-slider-d2 .am-slider-content p{margin:0;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;font-size:1.4rem}.am-slider-d2 .am-slider-title{font-weight:400;margin-bottom:5px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-d2 .am-slider-more{color:#eee;font-size:1.3rem;background-color:#0e90d2;padding:2px 10px}.am-slider-d2 .am-control-nav{width:100%;position:absolute;bottom:-15px;text-align:center}.am-slider-d2 .am-control-nav li{margin:0 6px;display:inline-block}.am-slider-d2 .am-control-nav li a{width:8px;height:8px;display:block;background-color:rgba(0,0,0,.5);cursor:pointer;text-indent:-9999px;border-radius:50%;font-size:0;line-height:0;-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,.3);box-shadow:inset 0 0 3px rgba(0,0,0,.3)}.am-slider-d2 .am-control-nav li a:hover{background:rgba(0,0,0,.5)}.am-slider-d2 .am-control-nav li a.am-active{background:#0e90d2;cursor:default}.am-slider-d2 .am-direction-nav,.am-slider-d2 .am-pauseplay{display:none}.am-slider-d3{margin-bottom:10px;-webkit-box-shadow:0 1px 4px rgba(0,0,0,.2);box-shadow:0 1px 4px rgba(0,0,0,.2)}.am-slider-d3 .am-viewport{max-height:2000px;-webkit-transition:all 1s ease;transition:all 1s ease}.loading .am-slider-d3 .am-viewport{max-height:300px}.am-slider-d3 .am-slider-desc{position:absolute;bottom:0;color:#fff;width:100%;background-color:rgba(0,0,0,.7);padding:8px 5px}.am-slider-d3 .am-slider-desc p{margin:0;font-size:1.3rem;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-d3 .am-slider-title{font-weight:400;margin-bottom:5px;display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-slider-d3 .am-control-thumbs{position:static;overflow:hidden}.am-slider-d3 .am-control-thumbs li{padding:12px 4px 4px;position:relative}.am-slider-d3 .am-control-thumbs img{width:100%;display:block;opacity:.85;cursor:pointer}.am-slider-d3 .am-control-thumbs img:hover{opacity:1}.am-slider-d3 .am-control-thumbs .am-active{opacity:1;cursor:default}.am-slider-d3 .am-control-thumbs .am-active+i{position:absolute;top:0;left:50%;content:"";display:inline-block;width:0;height:0;vertical-align:middle;border-top:8px solid rgba(0,0,0,.7);border-right:8px solid transparent;border-left:8px solid transparent;border-bottom:0 dotted;-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);margin-left:-4px;-webkit-transition:all .2s;transition:all .2s}.am-slider-d3 .am-direction-nav,.am-slider-d3 .am-pauseplay{display:none}.am-slider-d3 .am-control-thumbs{display:table}.am-slider-d3 .am-control-thumbs li{display:table-cell;width:1%}[data-am-widget=tabs]{margin:10px}[data-am-widget=tabs] .am-tabs-nav{width:100%;padding:0;margin:0;list-style:none;text-align:center;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}[data-am-widget=tabs] .am-tabs-nav li{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}[data-am-widget=tabs] .am-tabs-nav a{display:block;word-wrap:normal;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.am-tabs-default .am-tabs-nav{line-height:40px;background-color:#eee}.am-tabs-default .am-tabs-nav a{color:#222;line-height:42px}.am-tabs-default .am-tabs-nav>.am-active a{background-color:#0e90d2;color:#fff}.am-tabs-d2 .am-tabs-nav{background-color:#eee}.am-tabs-d2 .am-tabs-nav li{height:42px}.am-tabs-d2 .am-tabs-nav a{color:#222;line-height:42px}.am-tabs-d2 .am-tabs-nav>.am-active{position:relative;background-color:#fcfcfc;border-bottom:2px solid #0e90d2}.am-tabs-d2 .am-tabs-nav>.am-active a{line-height:40px;color:#0e90d2}.am-tabs-d2 .am-tabs-nav>.am-active:after{position:absolute;width:0;height:0;bottom:0;left:50%;margin-left:-5px;border:6px rgba(0,0,0,0) solid;content:"";z-index:1;border-bottom-color:#0e90d2}.am-titlebar{margin-top:20px;height:45px;font-size:100%}.am-titlebar h2{margin-top:0;margin-bottom:0;font-size:1.6rem}.am-titlebar .am-titlebar-title img{height:24px;width:auto}.am-titlebar-default{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin-left:10px;margin-right:10px;background-color:transparent;border-bottom:1px solid #dedede;line-height:44px}.am-titlebar-default a{color:#0e90d2}.am-titlebar-default .am-titlebar-title{position:relative;padding-left:12px;color:#0e90d2;font-size:1.8rem;text-align:left;font-weight:700}.am-titlebar-default .am-titlebar-title:before{content:"";position:absolute;left:2px;top:8px;bottom:8px;border-left:3px solid #0e90d2}.am-titlebar-default .am-titlebar-nav{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;text-align:right}.am-titlebar-default .am-titlebar-nav a{margin-right:10px}.am-titlebar-default .am-titlebar-nav a:last-child{margin-right:5px}.am-titlebar-multi{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background-color:#f5f5f5;border-top:2px solid #3bb4f2;border-bottom:1px solid #e8e8e8}.am-titlebar-multi a{color:#0e90d2}.am-titlebar-multi .am-titlebar-title{padding-left:10px;color:#0e90d2;font-size:1.8rem;text-align:left;font-weight:700;line-height:42px}.am-titlebar-multi .am-titlebar-nav{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;text-align:right;line-height:42px}.am-titlebar-multi .am-titlebar-nav a{margin-right:10px}.am-titlebar-cols{position:relative;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-left:10px;background-color:#f5f5f5;color:#555;font-size:18px;border-top:2px solid #e1e1e1;line-height:41px}.am-titlebar-cols a{color:#555}.am-titlebar-cols .am-titlebar-title{color:#0e90d2;margin-right:15px;border-bottom:2px solid #0e90d2;font-weight:700}.am-titlebar-cols .am-titlebar-title a{color:#0e90d2}.am-titlebar-cols .am-titlebar-nav{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.am-titlebar-cols .am-titlebar-nav a{display:inline-block;margin-right:15px;line-height:41px;border-bottom:2px solid transparent}.am-titlebar-cols .am-titlebar-nav a:hover{color:#3c3c3c;border-bottom-color:#0e90d2}.am-titlebar-cols .am-titlebar-nav a:last-child{margin-right:10px}.am-wechatpay .am-wechatpay-btn{margin-top:1rem;margin-bottom:1rem} \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/css/app.css b/Day61-65/code/project_of_tornado/assets/css/app.css deleted file mode 100644 index 8b52e27..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/app.css +++ /dev/null @@ -1,1912 +0,0 @@ -ul, -li { - list-style: none; - padding: 0; - margin: 0; -} -header { - z-index: 1200; - position: relative; -} -.tpl-header-logo { - width: 240px; - height: 57px; - display: table; - text-align: center; - position: relative; - z-index: 1300; -} -.tpl-header-logo a { - display: table-cell; - vertical-align: middle; -} -.tpl-header-logo img { - width: 170px; -} -.tpl-header-fluid { - margin-left: 240px; - height: 56px; - padding-left: 20px; - padding-right: 20px; -} -.tpl-header-switch-button { - margin-top: 0px; - margin-bottom: 0px; - float: left; - color: #cfcfcf; - margin-left: -20px; - margin-right: 0; - border: 0; - border-radius: 0; - padding: 0px 22px; - font-size: 22px; - line-height: 55px; -} -.tpl-header-switch-button:hover { - outline: none; -} -.tpl-header-search-form { - height: 54px; - line-height: 52px; - margin-left: 10px; -} -.tpl-header-search-box, -.tpl-header-search-btn { - transition: all 0.4s ease-in-out; - color: #848c90; - background: none; - border: none; - outline: none; -} -.tpl-header-search-box { - font-size: 14px; -} -.tpl-header-search-box:hover, -.tpl-header-search-box:active { - color: #fff; -} -.tpl-header-search-btn { - font-size: 15px; -} -.tpl-header-search-btn:hover, -.tpl-header-search-btn:active { - color: #fff; -} -.tpl-header-navbar { - color: #fff; -} -.tpl-header-navbar li { - float: left; -} -.tpl-header-navbar a { - line-height: 56px; - display: block; - padding: 0 16px; - position: relative; -} -.tpl-header-navbar a .item-feed-badge { - position: absolute; - top: 9px; - left: 25px; -} -ul.tpl-dropdown-content { - padding: 10px; - margin-top: 0; - width: 300px; - background-color: #2f3638; - border: 1px solid #525e62; - border-radius: 0; -} -ul.tpl-dropdown-content li { - float: none; -} -ul.tpl-dropdown-content:before, -ul.tpl-dropdown-content:after { - display: none; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-title { - font-size: 12px; - float: left; - color: rgba(255, 255, 255, 0.7); -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-time { - float: right; - text-align: right; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; - width: 50px; - margin-left: 10px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications:last-child .tpl-dropdown-menu-notifications-item { - text-align: center; - border: none; - font-size: 12px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications:last-child .tpl-dropdown-menu-notifications-item i { - margin-left: -6px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-messages:last-child .tpl-dropdown-menu-messages-item { - text-align: center; - border: none; - font-size: 12px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-messages:last-child .tpl-dropdown-menu-messages-item i { - margin-left: -6px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item { - padding: 12px; - color: #fff; - line-height: 20px; - border-bottom: 1px solid rgba(255, 255, 255, 0.15); -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item:hover, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item:hover, -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item:focus, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item:focus { - background-color: #465154; - color: #fff; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .menu-messages-ico, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-ico { - line-height: initial; - float: left; - width: 35px; - height: 35px; - border-radius: 50%; - margin-right: 10px; - margin-top: 6px; - overflow: hidden; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .menu-messages-ico img, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-ico img { - width: 100%; - height: auto; - vertical-align: middle; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .menu-messages-time, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-time { - float: right; - text-align: right; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; - width: 40px; - margin-left: 10px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .menu-messages-content, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-content { - display: block; - font-size: 13px; - margin-left: 45px; - margin-right: 50px; -} -ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .menu-messages-content .menu-messages-content-time, -ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-content .menu-messages-content-time { - margin-top: 3px; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; -} -.am-dimmer { - z-index: 1200; -} -.am-modal { - z-index: 1300; -} -.am-datepicker-dropdown { - z-index: 1400; -} -.tpl-skiner { - transition: all 0.4s ease-in-out; - position: fixed; - z-index: 10000; - right: -130px; - top: 65px; -} -.tpl-skiner.active { - right: 0px; -} -.tpl-skiner-content { - background: rgba(0, 0, 0, 0.7); - width: 130px; - padding: 15px; - border-radius: 4px 0 0 4px; - overflow: hidden; -} -.fc-content .am-icon-close { - position: absolute; - right: 0; - top: 0px; -} -.tpl-skiner-toggle { - position: absolute; - top: 5px; - left: -40px; - width: 40px; - color: #969a9b; - font-size: 20px; - height: 40px; - line-height: 40px; - text-align: center; - background: rgba(0, 0, 0, 0.7); - cursor: pointer; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; -} -.tpl-skiner-content-title { - margin: 0; - margin-bottom: 4px; - padding-bottom: 4px; - font-size: 16px; - text-transform: uppercase; - color: #fff; - border-bottom: 1px solid rgba(255, 255, 255, 0.3); -} -.tpl-skiner-content-bar { - padding-top: 10px; -} -.tpl-skiner-content-bar .skiner-color { - transition: all 0.4s ease-in-out; - float: left; - width: 25px; - height: 25px; - margin-right: 10px; - cursor: pointer; -} -.tpl-skiner-content-bar .skiner-white { - background: #fff; - border: 2px solid #eee; -} -.tpl-skiner-content-bar .skiner-black { - background: #000; - border: 2px solid #222; -} -.sub-active { - color: #fff!important; -} -.left-sidebar { - transition: all 0.4s ease-in-out; - width: 240px; - min-height: 100%; - padding-top: 57px; - position: absolute; - z-index: 1104; - top: 0; - left: 0px; -} -.left-sidebar.xs-active { - left: 0px; -} -.left-sidebar.active { - left: -240px; -} -.tpl-sidebar-user-panel { - padding: 22px; - padding-top: 28px; -} -.tpl-user-panel-profile-picture { - border-radius: 50%; - width: 82px; - height: 82px; - margin-bottom: 10px; - overflow: hidden; -} -.tpl-user-panel-profile-picture img { - width: auto; - height: 82px; - vertical-align: middle; -} -.tpl-user-panel-status-icon { - margin-right: 2px; -} -.user-panel-logged-in-text { - display: block; - color: #cfcfcf; - font-size: 14px; -} -.tpl-user-panel-action-link { - color: #6d787c; - font-size: 12px; -} -.tpl-user-panel-action-link:hover { - color: #a2aaad; -} -.sidebar-nav { - list-style-type: none; - padding: 0; - margin: 0; -} -.sidebar-nav-sub { - display: none; -} -.sidebar-nav-sub .sidebar-nav-link { - font-size: 12px; - padding-left: 30px; -} -.sidebar-nav-sub .sidebar-nav-link a { - font-size: 12px; - padding-left: 0; -} -.sidebar-nav-sub .sidebar-nav-link-logo { - margin-right: 8px; - width: 20px; - font-size: 16px; -} -.sidebar-nav-sub-ico-rotate { - -webkit-transform: rotate(180deg); - transform: rotate(180deg); - -webkit-transition: all 300ms; - transition: all 300ms; -} -.sidebar-nav-link-logo-ico { - margin-top: 5px; -} -.sidebar-nav-heading { - padding: 24px 17px; - font-size: 15px; - font-weight: 500; -} -.sidebar-nav-heading-info { - font-size: 12px; - color: #868E8E; - padding-left: 10px; -} -.sidebar-nav-link-logo { - margin-right: 8px; - width: 20px; - font-size: 16px; -} -.sidebar-nav-link { - color: #fff; -} -.sidebar-nav-link a { - display: block; - color: #868E8E; - padding: 10px 17px; - border-left: #282d2f 3px solid; - font-size: 14px; - cursor: pointer; -} -.sidebar-nav-link a.active { - cursor: pointer; - border-left: #1CA2CE 3px solid; - color: #fff; -} -.sidebar-nav-link a:hover { - color: #fff; -} -.tpl-content-wrapper { - transition: all 0.4s ease-in-out; - position: relative; - margin-left: 240px; - z-index: 1101; - min-height: 922px; - border-bottom-left-radius: 3px; -} -.tpl-content-wrapper.xs-active { - margin-left: 240px; -} -.tpl-content-wrapper.active { - margin-left: 0; -} -.page-header { - background: #424b4f; - margin-top: 0; - margin-bottom: 0; - padding: 40px 0; - border-bottom: 0; -} -.container-fluid { - margin-top: 0; - margin-bottom: 0; - padding: 40px 0; - border-bottom: 0; - padding-left: 20px; - padding-right: 20px; -} -.row { - margin-right: -10px; - margin-left: -10px; -} -.page-header-description { - margin-top: 4px; - margin-bottom: 0; - font-size: 14px; - color: #e6e6e6; -} -.page-header-heading { - font-size: 20px; - font-weight: 400; -} -.page-header-heading .page-header-heading-ico { - font-size: 28px; - position: relative; - top: 3px; -} -.page-header-heading small { - font-weight: normal; - line-height: 1; - color: #B3B3B3; -} -.page-header-button { - transition: all 0.4s ease-in-out; - opacity: 0.3; - float: right; - outline: none; - border: 1px solid #fff; - padding: 16px 36px; - font-size: 23px; - line-height: 23px; - border-radius: 0; - padding-top: 14px; - color: #fff; - background-color: rgba(0, 0, 0, 0); - font-weight: 500; -} -.page-header-button:hover { - background-color: #ffffff; - color: #333; - opacity: 1; -} -.widget { - width: 100%; - min-height: 148px; - margin-bottom: 20px; - border-radius: 0; - position: relative; -} -.widget-head { - width: 100%; - padding: 15px; -} -.widget-title { - font-size: 14px; -} -.widget-fluctuation-period-text { - display: inline-block; - font-size: 16px; - line-height: 20px; - margin-bottom: 9px; -} -.widget-body { - padding: 13px 15px; - width: 100%; -} -.row-content { - padding: 20px; -} -.widget-fluctuation-description-text { - margin-top: 4px; - display: block; - font-size: 12px; - line-height: 13px; -} -.widget-fluctuation-description-amount { - display: block; - font-size: 20px; - line-height: 22px; -} -.widget-statistic-header { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - text-transform: uppercase; - margin-bottom: 8px; -} -.widget-body-md { - height: 200px; -} -.widget-body-lg { - min-height: 330px; -} -.widget-margin-bottom-lg { - margin-bottom: 20px; -} -.tpl-table-black-operation a { - display: inline-block; - padding: 5px 6px; - font-size: 12px; - line-height: 12px; -} -.tpl-switch input[type="checkbox"] { - position: absolute; - opacity: 0; - width: 50px; - height: 20px; -} -.tpl-switch input[type="checkbox"].ios-switch + div { - vertical-align: middle; - width: 40px; - height: 20px; - border-radius: 999px; - background-color: rgba(0, 0, 0, 0.1); - -webkit-transition-duration: .4s; - -webkit-transition-property: background-color, box-shadow; - margin-top: 6px; -} -.tpl-switch input[type="checkbox"].ios-switch:checked + div { - width: 40px; - background-position: 0 0; - background-color: #36c6d3; -} -.tpl-switch input[type="checkbox"].tinyswitch.ios-switch + div { - width: 34px; - height: 18px; -} -.tpl-switch input[type="checkbox"].bigswitch.ios-switch + div { - width: 50px; - height: 25px; -} -.tpl-switch input[type="checkbox"].green.ios-switch:checked + div { - background-color: #00e359; - border: 1px solid #00a23f; - box-shadow: inset 0 0 0 10px #00e359; -} -.tpl-switch input[type="checkbox"].ios-switch + div > div { - float: left; - width: 18px; - height: 18px; - border-radius: inherit; - background: #ffffff; - -webkit-transition-timing-function: cubic-bezier(0.54, 1.85, 0.5, 1); - -webkit-transition-duration: 0.4s; - -webkit-transition-property: transform, background-color, box-shadow; - -moz-transition-timing-function: cubic-bezier(0.54, 1.85, 0.5, 1); - -moz-transition-duration: 0.4s; - -moz-transition-property: transform, background-color; - pointer-events: none; - margin-top: 1px; - margin-left: 1px; -} -.tpl-switch input[type="checkbox"].ios-switch:checked + div > div { - -webkit-transform: translate3d(20px, 0, 0); - -moz-transform: translate3d(20px, 0, 0); - background-color: #ffffff; -} -.tpl-switch input[type="checkbox"].tinyswitch.ios-switch + div > div { - width: 16px; - height: 16px; - margin-top: 1px; -} -.tpl-switch input[type="checkbox"].tinyswitch.ios-switch:checked + div > div { - -webkit-transform: translate3d(16px, 0, 0); - -moz-transform: translate3d(16px, 0, 0); - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px #0850ac; -} -.tpl-switch input[type="checkbox"].bigswitch.ios-switch + div > div { - width: 23px; - height: 23px; - margin-top: 1px; -} -.tpl-switch input[type="checkbox"].bigswitch.ios-switch:checked + div > div { - -webkit-transform: translate3d(25px, 0, 0); - -moz-transform: translate3d(16px, 0, 0); -} -.tpl-switch input[type="checkbox"].green.ios-switch:checked + div > div { - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 1px #00a23f; -} -.tpl-page-state { - width: 100%; -} -.tpl-page-state-title { - font-size: 40px; - font-weight: bold; -} -.tpl-page-state-content { - padding: 10px 0; -} -.tpl-login { - width: 100%; -} -.tpl-login-logo { - max-width: 159px; - height: 205px; - margin: 0 auto; - margin-bottom: 20px; -} -.tpl-login-title { - width: 100%; - font-size: 24px; -} -.tpl-login-content { - width: 300px; - margin: 12% auto 0; -} -.tpl-login-remember-me { - color: #B3B3B3; - font-size: 14px; -} -.tpl-login-remember-me label { - position: relative; - top: -2px; -} -.tpl-login-content-info { - color: #B3B3B3; - font-size: 14px; -} -.cl-p { - padding: 0!important; -} -.tpl-table-line-img { - max-width: 100px; - padding: 2px; -} -.tpl-table-list-select { - text-align: right; -} -.fc-button-group, -.fc button { - display: block; -} -.theme-white { - background: #e9ecf3; -} -.theme-white .sidebar-nav-sub .sidebar-nav-link-logo { - margin-left: 10px; -} -.theme-white .tpl-header-search-box:hover, -.theme-white .tpl-header-search-box:active .tpl-error-title { - color: #848c90; -} -.theme-white .tpl-error-title-info { - line-height: 30px; - font-size: 21px; - margin-top: 20px; - text-align: center; - color: #dce2ec; -} -.theme-white .tpl-error-btn { - background: #03a9f3; - border: 1px solid #03a9f3; - border-radius: 30px; - padding: 6px 20px 8px; -} -.theme-white .tpl-error-content { - margin-top: 20px; - margin-bottom: 20px; - font-size: 16px; - text-align: center; - color: #96a2b4; -} -.theme-white .tpl-calendar-box { - background: #fff; - border-radius: 4px; - padding: 20px; -} -.theme-white .tpl-calendar-box .fc-event { - border-radius: 0; - background: #03a9f3; - border: 1px solid #14b0f6; -} -.theme-white .tpl-calendar-box .fc-axis { - color: #868E8E; -} -.theme-white .tpl-calendar-box .fc-unthemed .fc-today { - background: #eee; -} -.theme-white .tpl-calendar-box .fc-more { - color: #868E8E; -} -.theme-white .tpl-calendar-box .fc th.fc-widget-header { - background: #32c5d2!important; - color: #ffffff; - font-size: 14px; - line-height: 20px; - padding: 7px 0px; - text-transform: uppercase; - border: none!important; -} -.theme-white .tpl-calendar-box .fc th.fc-widget-header a { - color: #fff; -} -.theme-white .tpl-calendar-box .fc-center h2 { - color: #868E8E; -} -.theme-white .tpl-calendar-box .fc-state-default { - background-image: none; - background: #fff; - font-size: 14px; - color: #868E8E; -} -.theme-white .tpl-calendar-box .fc th, -.theme-white .tpl-calendar-box .fc td, -.theme-white .tpl-calendar-box .fc hr, -.theme-white .tpl-calendar-box .fc thead, -.theme-white .tpl-calendar-box .fc tbody, -.theme-white .tpl-calendar-box .fc-row { - border-color: #eee!important; -} -.theme-white .tpl-calendar-box .fc-day-number { - color: #868E8E; - padding-right: 6px; -} -.theme-white .tpl-calendar-box .fc th { - color: #868E8E; - font-weight: normal; - font-size: 14px; - padding: 6px 0; -} -.theme-white .tpl-login-logo { - background: url(../img/logoa.png) center no-repeat; -} -.theme-white .sub-active { - color: #23abf0!important; -} -.theme-white .tpl-table-line-img { - border: 1px solid #ddd; -} -.theme-white .tpl-pagination .am-disabled a, -.theme-white .tpl-pagination li a { - color: #23abf0; - border-radius: 3px; - padding: 6px 12px; -} -.theme-white .tpl-pagination .am-active a { - background: #23abf0; - color: #fff; - border: 1px solid #23abf0; - padding: 6px 12px; -} -.theme-white .tpl-login-btn { - background-color: #32c5d2; - border: none; - padding: 10px 16px; - font-size: 14px; - line-height: 14px; - outline: none; -} -.theme-white .tpl-login-btn:hover, -.theme-white .tpl-login-btn:active { - background: #22b2e1; - color: #fff; -} -.theme-white .tpl-login-title { - color: #697882; -} -.theme-white .tpl-login-title strong { - color: #39bae4; -} -.theme-white .tpl-login-content { - width: 500px; - padding: 40px 40px 25px; - background-color: #fff; - border-radius: 4px; -} -.theme-white .tpl-form-line-form, -.theme-white .tpl-form-border-form { - padding-top: 20px; -} -.theme-white .tpl-form-border-form input[type=number]:focus, -.theme-white .tpl-form-border-form input[type=search]:focus, -.theme-white .tpl-form-border-form input[type=text]:focus, -.theme-white .tpl-form-border-form input[type=password]:focus, -.theme-white .tpl-form-border-form input[type=datetime]:focus, -.theme-white .tpl-form-border-form input[type=datetime-local]:focus, -.theme-white .tpl-form-border-form input[type=date]:focus, -.theme-white .tpl-form-border-form input[type=month]:focus, -.theme-white .tpl-form-border-form input[type=time]:focus, -.theme-white .tpl-form-border-form input[type=week]:focus, -.theme-white .tpl-form-border-form input[type=email]:focus, -.theme-white .tpl-form-border-form input[type=url]:focus, -.theme-white .tpl-form-border-form input[type=tel]:focus, -.theme-white .tpl-form-border-form input[type=color]:focus, -.theme-white .tpl-form-border-form select:focus, -.theme-white .tpl-form-border-form textarea:focus, -.theme-white .am-form-field:focus { - -webkit-box-shadow: none; - box-shadow: none; -} -.theme-white .tpl-form-border-form input[type=number], -.theme-white .tpl-form-border-form input[type=search], -.theme-white .tpl-form-border-form input[type=text], -.theme-white .tpl-form-border-form input[type=password], -.theme-white .tpl-form-border-form input[type=datetime], -.theme-white .tpl-form-border-form input[type=datetime-local], -.theme-white .tpl-form-border-form input[type=date], -.theme-white .tpl-form-border-form input[type=month], -.theme-white .tpl-form-border-form input[type=time], -.theme-white .tpl-form-border-form input[type=week], -.theme-white .tpl-form-border-form input[type=email], -.theme-white .tpl-form-border-form input[type=url], -.theme-white .tpl-form-border-form input[type=tel], -.theme-white .tpl-form-border-form input[type=color], -.theme-white .tpl-form-border-form select, -.theme-white .tpl-form-border-form textarea, -.theme-white .am-form-field { - display: block; - width: 100%; - padding: 6px 12px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border: 1px solid #c2cad8; - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - text-indent: .5em; - -o-border-radius: 0; - border-radius: 0; - color: #555; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} -.theme-white .tpl-form-border-form .am-checkbox, -.theme-white .tpl-form-border-form .am-checkbox-inline, -.theme-white .tpl-form-border-form .am-form-label, -.theme-white .tpl-form-border-form .am-radio, -.theme-white .tpl-form-border-form .am-radio-inline { - margin-top: 0; - margin-bottom: 0; -} -.theme-white .tpl-form-border-form .am-form-group:after { - clear: both; -} -.theme-white .tpl-form-border-form .am-form-group:after, -.theme-white .tpl-form-border-form .am-form-group:before { - content: " "; - display: table; -} -.theme-white .tpl-form-border-form .am-form-label { - padding-top: 5px; - font-size: 16px; - color: #888; - font-weight: inherit; - text-align: right; -} -.theme-white .tpl-form-border-form .am-form-group { - /*padding: 20px 0;*/ -} -.theme-white .tpl-form-border-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} -.theme-white .tpl-form-line-form input[type=number]:focus, -.theme-white .tpl-form-line-form input[type=search]:focus, -.theme-white .tpl-form-line-form input[type=text]:focus, -.theme-white .tpl-form-line-form input[type=password]:focus, -.theme-white .tpl-form-line-form input[type=datetime]:focus, -.theme-white .tpl-form-line-form input[type=datetime-local]:focus, -.theme-white .tpl-form-line-form input[type=date]:focus, -.theme-white .tpl-form-line-form input[type=month]:focus, -.theme-white .tpl-form-line-form input[type=time]:focus, -.theme-white .tpl-form-line-form input[type=week]:focus, -.theme-white .tpl-form-line-form input[type=email]:focus, -.theme-white .tpl-form-line-form input[type=url]:focus, -.theme-white .tpl-form-line-form input[type=tel]:focus, -.theme-white .tpl-form-line-form input[type=color]:focus, -.theme-white .tpl-form-line-form select:focus, -.theme-white .tpl-form-line-form textarea:focus, -.theme-white .am-form-field:focus { - -webkit-box-shadow: none; - box-shadow: none; -} -.theme-white .tpl-form-line-form input[type=number], -.theme-white .tpl-form-line-form input[type=search], -.theme-white .tpl-form-line-form input[type=text], -.theme-white .tpl-form-line-form input[type=password], -.theme-white .tpl-form-line-form input[type=datetime], -.theme-white .tpl-form-line-form input[type=datetime-local], -.theme-white .tpl-form-line-form input[type=date], -.theme-white .tpl-form-line-form input[type=month], -.theme-white .tpl-form-line-form input[type=time], -.theme-white .tpl-form-line-form input[type=week], -.theme-white .tpl-form-line-form input[type=email], -.theme-white .tpl-form-line-form input[type=url], -.theme-white .tpl-form-line-form input[type=tel], -.theme-white .tpl-form-line-form input[type=color], -.theme-white .tpl-form-line-form select, -.theme-white .tpl-form-line-form textarea, -.theme-white .am-form-field { - display: block; - width: 100%; - padding: 6px 12px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border-bottom: 1px solid #c2cad8; - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #555; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} -.theme-white .tpl-form-line-form .am-checkbox, -.theme-white .tpl-form-line-form .am-checkbox-inline, -.theme-white .tpl-form-line-form .am-form-label, -.theme-white .tpl-form-line-form .am-radio, -.theme-white .tpl-form-line-form .am-radio-inline { - margin-top: 0; - margin-bottom: 0; -} -.theme-white .tpl-form-line-form .am-form-group:after { - clear: both; -} -.theme-white .tpl-form-line-form .am-form-group:after, -.theme-white .tpl-form-line-form .am-form-group:before { - content: " "; - display: table; -} -.theme-white .tpl-form-line-form .am-form-label { - padding-top: 5px; - font-size: 16px; - color: #888; - font-weight: inherit; - text-align: right; -} -.theme-white .tpl-form-line-form .am-form-group { - /*padding: 20px 0;*/ -} -.theme-white .tpl-form-line-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} -.theme-white .tpl-table-black-operation a { - border: 1px solid #36c6d3; - color: #36c6d3; -} -.theme-white .tpl-table-black-operation a:hover { - background: #36c6d3; - color: #fff; -} -.theme-white .tpl-table-black-operation a.tpl-table-black-operation-del { - border: 1px solid #e7505a; - color: #e7505a; -} -.theme-white .tpl-table-black-operation a.tpl-table-black-operation-del:hover { - background: #e7505a; - color: #fff; -} -.theme-white .tpl-amendment-echarts { - left: -17px; -} -.theme-white .tpl-user-card { - border: 1px solid #3598dc; - border-top: 2px solid #3598dc; - background: #3598dc; - color: #ffffff; - border-radius: 4px; -} -.theme-white .tpl-user-card-title { - font-size: 26px; - margin-top: 0; - font-weight: 300; - margin-top: 25px; - margin-bottom: 10px; -} -.theme-white .achievement-subheading { - font-size: 12px; - margin-top: 0; - margin-bottom: 15px; -} -.theme-white .achievement-image { - border-radius: 50%; - margin-bottom: 22px; -} -.theme-white .achievement-description { - margin: 0; - font-size: 12px; -} -.theme-white .tpl-table-black { - color: #838FA1; -} -.theme-white .tpl-table-black thead > tr > th { - font-size: 14px; - padding: 6px; -} -.theme-white .tpl-table-black tbody > tr > td { - font-size: 14px; - padding: 7px 6px; -} -.theme-white .tpl-table-black tfoot > tr > th { - font-size: 14px; - padding: 6px 0; -} -.theme-white .am-progress { - height: 12px; -} -.theme-white .am-progress-title { - font-size: 14px; - margin-bottom: 8px; -} -.theme-white .widget-fluctuation-tpl-btn { - margin-top: 6px; - display: block; - color: #fff; - font-size: 12px; - padding: 8px 14px; - outline: none; - background-color: #e7505a; - border: 1px solid #e7505a; -} -.theme-white .widget-fluctuation-tpl-btn:hover { - background: transparent; - color: #e7505a; -} -.theme-white .widget-fluctuation-description-text { - color: #c5cacd; -} -.theme-white .widget-fluctuation-period-text { - color: #838FA1; -} -.theme-white .text-success { - color: #5eb95e; -} -.theme-white .widget-head { - border-bottom: 1px solid #eef1f5; -} -.theme-white .widget-function a { - color: #838FA1; -} -.theme-white .widget-function a:hover { - color: #a7bdcd; -} -.theme-white .widget { - padding: 10px 20px 13px; - background-color: #fff; - border-radius: 4px; - color: #838FA1; -} -.theme-white .widget-title { - font-size: 16px; -} -.theme-white .widget-primary { - min-height: 174px; - border: 1px solid #32c5d2; - border-top: 2px solid #32c5d2; - background: #32c5d2; - color: #ffffff; - padding: 12px 17px; - padding-left: 22px; -} -.theme-white .widget-statistic-icon { - position: absolute; - z-index: 30; - right: 30px; - top: 24px; - font-size: 70px; - color: #46cad6; -} -.theme-white .widget-statistic-description { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - line-height: 14px; - padding-top: 8px; - color: #fff; -} -.theme-white .widget-statistic-value { - position: relative; - z-index: 35; - font-weight: 300; - display: block; - color: #fff; - font-size: 46px; - line-height: 46px; - margin-bottom: 8px; -} -.theme-white .widget-statistic-header { - padding-top: 18px; - color: #fff; -} -.theme-white .widget-purple { - padding: 12px 17px; - border: 1px solid #8E44AD; - border-top: 2px solid #8E44AD; - background: #8E44AD; - color: #ffffff; - min-height: 174px; -} -.theme-white .widget-purple .widget-statistic-icon { - color: #9956b5; -} -.theme-white .widget-purple .widget-statistic-header { - color: #ded5e7; -} -.theme-white .widget-purple .widget-statistic-description { - color: #ded5e7; -} -.theme-white .page-header-button { - opacity: .8; - border: 1px solid #32c5d2; - background: #32c5d2; - color: #fff; -} -.theme-white .page-header-button:hover { - opacity: 1; -} -.theme-white .page-header-description { - color: #666; -} -.theme-white .page-header-heading { - color: #666; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-content .menu-messages-content-time { - color: #96a5aa; -} -.theme-white ul.tpl-dropdown-content { - background: #fff; - border: 1px solid #ddd; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item, -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item { - border-bottom: 1px solid #eee; - color: #999; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item:hover, -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item:hover { - background-color: #f5f5f5; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-item .tpl-dropdown-menu-notifications-time, -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .tpl-dropdown-menu-notifications-time { - color: #999; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item:hover { - background-color: #f5f5f5; -} -.theme-white ul.tpl-dropdown-content .tpl-dropdown-menu-notifications-title { - color: #999; -} -.theme-white .sidebar-nav-link a { - border-left: #fff 3px solid; -} -.theme-white .sidebar-nav-link a:hover { - background: #f2f6f9; - color: #868E8E; - border-left: #3bb4f2 3px solid; -} -.theme-white .sidebar-nav-link a.active { - background: #f2f6f9; - color: #868E8E; - border-left: #3bb4f2 3px solid; -} -.theme-white .sidebar-nav-heading { - color: #999; - border-bottom: 1px solid #eee; -} -.theme-white .tpl-sidebar-user-panel { - background: #fff; - border-bottom: 1px solid #eee; -} -.theme-white .tpl-content-wrapper { - background: #e9ecf3; -} -.theme-white .tpl-header-fluid { - background: #fff; - border-top: 1px solid #eee; -} -.theme-white .tpl-header-logo { - background: #fff; - border-bottom: 1px solid #eee; -} -.theme-white .tpl-header-switch-button { - background: #fff; - border-right: 1px solid #eee; - border-left: 1px solid #eee; -} -.theme-white .tpl-header-switch-button:hover { - background: #fff; - color: #999; -} -.theme-white .tpl-header-navbar a { - color: #999; -} -.theme-white .tpl-header-navbar a:hover { - color: #999; -} -.theme-white .left-sidebar { - background: #fff; -} -.theme-white .widget-color-green { - border: 1px solid #32c5d2; - border-top: 2px solid #32c5d2; - background: #32c5d2; - color: #ffffff; -} -.theme-white .widget-color-green .widget-fluctuation-period-text { - color: #fff; -} -.theme-white .widget-color-green .widget-head { - border-bottom: 1px solid #2bb8c4; -} -.theme-white .widget-color-green .widget-fluctuation-description-text { - color: #bbe7f6; -} -.theme-white .widget-color-green .widget-function a { - color: #42bde5; -} -.theme-white .widget-color-green .widget-function a:hover { - color: #fff; -} -.theme-black { - background-color: #282d2f; -} -.theme-black .tpl-am-model-bd { - background: #424b4f; -} -.theme-black .tpl-model-dialog { - background: #424b4f; -} -.theme-black .tpl-error-title { - font-size: 210px; - line-height: 220px; - color: #868E8E; -} -.theme-black .tpl-error-title-info { - line-height: 30px; - font-size: 21px; - margin-top: 20px; - text-align: center; - color: #868E8E; -} -.theme-black .tpl-error-btn { - background: #03a9f3; - border: 1px solid #03a9f3; - border-radius: 30px; - padding: 6px 20px 8px; -} -.theme-black .tpl-error-content { - margin-top: 20px; - margin-bottom: 20px; - font-size: 16px; - text-align: center; - color: #cfcfcf; -} -.theme-black .tpl-calendar-box { - background: #424b4f; - padding: 20px; -} -.theme-black .tpl-calendar-box .fc-button { - border-radius: 0; - box-shadow: 0; -} -.theme-black .tpl-calendar-box .fc-event { - border-radius: 0; - background: #03a9f3; -} -.theme-black .tpl-calendar-box .fc-axis { - color: #fff; -} -.theme-black .tpl-calendar-box .fc-unthemed .fc-today { - background: #3a4144; -} -.theme-black .tpl-calendar-box .fc-more { - color: #fff; -} -.theme-black .tpl-calendar-box .fc th.fc-widget-header { - background: #9675ce!important; - color: #ffffff; - font-size: 14px; - line-height: 20px; - padding: 7px 0px; - text-transform: uppercase; - border: none!important; -} -.theme-black .tpl-calendar-box .fc th.fc-widget-header a { - color: #fff; -} -.theme-black .tpl-calendar-box .fc-center h2 { - color: #fff; -} -.theme-black .tpl-calendar-box .fc-state-default { - background-image: none; - background: #fff; - font-size: 14px; -} -.theme-black .tpl-calendar-box .fc th, -.theme-black .tpl-calendar-box .fc td, -.theme-black .tpl-calendar-box .fc hr, -.theme-black .tpl-calendar-box .fc thead, -.theme-black .tpl-calendar-box .fc tbody, -.theme-black .tpl-calendar-box .fc-row { - border-color: rgba(120, 130, 140, 0.4) !important; -} -.theme-black .tpl-calendar-box .fc-day-number { - color: #868E8E; - padding-right: 6px; -} -.theme-black .tpl-calendar-box .fc th { - color: #868E8E; - font-weight: normal; - font-size: 14px; - padding: 6px 0; -} -.theme-black .tpl-login-logo { - background: url(../img/logob.png) center no-repeat; -} -.theme-black .tpl-table-line-img { - max-width: 100px; - padding: 2px; - border: none; -} -.theme-black .tpl-table-list-field { - border: none; -} -.theme-black .tpl-table-list-select .am-dropdown-content { - color: #888; -} -.theme-black .tpl-table-list-select .am-selected-btn { - border: 1px solid rgba(255, 255, 255, 0.2); - color: #fff; -} -.theme-black .tpl-table-list-select .am-btn-default.am-active, -.theme-black .tpl-table-list-select .am-btn-default:active, -.theme-black .tpl-table-list-select .am-dropdown.am-active .am-btn-default.am-dropdown-toggle { - border: 1px solid rgba(255, 255, 255, 0.2); - color: #fff; - background: #5d6468; -} -.theme-black .tpl-pagination .am-disabled a, -.theme-black .tpl-pagination li a { - color: #fff; - padding: 6px 12px; - background: #3f4649; - border: none; -} -.theme-black .tpl-pagination .am-active a { - background: #167fa1; - color: #fff; - border: 1px solid #167fa1; - padding: 6px 12px; -} -.theme-black .tpl-login-btn { - border: 1px solid #b5b5b5; - background-color: rgba(0, 0, 0, 0); - padding: 10px 16px; - font-size: 14px; - line-height: 14px; - color: #b5b5b5; -} -.theme-black .tpl-login-btn:hover, -.theme-black .tpl-login-btn:active { - background: #b5b5b5; - color: #fff; -} -.theme-black .tpl-login-title { - color: #fff; -} -.theme-black .tpl-login-title strong { - color: #39bae4; -} -.theme-black .tpl-form-line-form, -.theme-black .tpl-form-border-form { - padding-top: 20px; -} -.theme-black .tpl-form-line-form .am-btn-default, -.theme-black .tpl-form-border-form .am-btn-default { - color: #fff; - border: 1px solid rgba(255, 255, 255, 0.2); -} -.theme-black .tpl-form-line-form .am-selected-text, -.theme-black .tpl-form-border-form .am-selected-text { - color: #888; -} -.theme-black .tpl-form-border-form input[type=number]:focus, -.theme-black .tpl-form-border-form input[type=search]:focus, -.theme-black .tpl-form-border-form input[type=text]:focus, -.theme-black .tpl-form-border-form input[type=password]:focus, -.theme-black .tpl-form-border-form input[type=datetime]:focus, -.theme-black .tpl-form-border-form input[type=datetime-local]:focus, -.theme-black .tpl-form-border-form input[type=date]:focus, -.theme-black .tpl-form-border-form input[type=month]:focus, -.theme-black .tpl-form-border-form input[type=time]:focus, -.theme-black .tpl-form-border-form input[type=week]:focus, -.theme-black .tpl-form-border-form input[type=email]:focus, -.theme-black .tpl-form-border-form input[type=url]:focus, -.theme-black .tpl-form-border-form input[type=tel]:focus, -.theme-black .tpl-form-border-form input[type=color]:focus, -.theme-black .tpl-form-border-form select:focus, -.theme-black .tpl-form-border-form textarea:focus, -.theme-black .am-form-field:focus { - -webkit-box-shadow: none; - box-shadow: none; -} -.theme-black .tpl-form-border-form input[type=number], -.theme-black .tpl-form-border-form input[type=search], -.theme-black .tpl-form-border-form input[type=text], -.theme-black .tpl-form-border-form input[type=password], -.theme-black .tpl-form-border-form input[type=datetime], -.theme-black .tpl-form-border-form input[type=datetime-local], -.theme-black .tpl-form-border-form input[type=date], -.theme-black .tpl-form-border-form input[type=month], -.theme-black .tpl-form-border-form input[type=time], -.theme-black .tpl-form-border-form input[type=week], -.theme-black .tpl-form-border-form input[type=email], -.theme-black .tpl-form-border-form input[type=url], -.theme-black .tpl-form-border-form input[type=tel], -.theme-black .tpl-form-border-form input[type=color], -.theme-black .tpl-form-border-form select, -.theme-black .tpl-form-border-form textarea, -.theme-black .am-form-field { - display: block; - width: 100%; - padding: 6px 12px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - text-indent: .5em; - border: 1px solid rgba(255, 255, 255, 0.2); - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #fff; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} -.theme-black .tpl-form-border-form .am-checkbox, -.theme-black .tpl-form-border-form .am-checkbox-inline, -.theme-black .tpl-form-border-form .am-form-label, -.theme-black .tpl-form-border-form .am-radio, -.theme-black .tpl-form-border-form .am-radio-inline { - margin-top: 0; - margin-bottom: 0; -} -.theme-black .tpl-form-border-form .am-form-group:after { - clear: both; -} -.theme-black .tpl-form-border-form .am-form-group:after, -.theme-black .tpl-form-border-form .am-form-group:before { - content: " "; - display: table; -} -.theme-black .tpl-form-border-form .am-form-label { - padding-top: 5px; - font-size: 16px; - color: #fff; - font-weight: inherit; - text-align: right; -} -.theme-black .tpl-form-border-form .am-form-group { - /*padding: 20px 0;*/ -} -.theme-black .tpl-form-border-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} -.theme-black .tpl-form-line-form input[type=number]:focus, -.theme-black .tpl-form-line-form input[type=search]:focus, -.theme-black .tpl-form-line-form input[type=text]:focus, -.theme-black .tpl-form-line-form input[type=password]:focus, -.theme-black .tpl-form-line-form input[type=datetime]:focus, -.theme-black .tpl-form-line-form input[type=datetime-local]:focus, -.theme-black .tpl-form-line-form input[type=date]:focus, -.theme-black .tpl-form-line-form input[type=month]:focus, -.theme-black .tpl-form-line-form input[type=time]:focus, -.theme-black .tpl-form-line-form input[type=week]:focus, -.theme-black .tpl-form-line-form input[type=email]:focus, -.theme-black .tpl-form-line-form input[type=url]:focus, -.theme-black .tpl-form-line-form input[type=tel]:focus, -.theme-black .tpl-form-line-form input[type=color]:focus, -.theme-black .tpl-form-line-form select:focus, -.theme-black .tpl-form-line-form textarea:focus, -.theme-black .am-form-field:focus { - -webkit-box-shadow: none; - box-shadow: none; -} -.theme-black .tpl-form-line-form input[type=number], -.theme-black .tpl-form-line-form input[type=search], -.theme-black .tpl-form-line-form input[type=text], -.theme-black .tpl-form-line-form input[type=password], -.theme-black .tpl-form-line-form input[type=datetime], -.theme-black .tpl-form-line-form input[type=datetime-local], -.theme-black .tpl-form-line-form input[type=date], -.theme-black .tpl-form-line-form input[type=month], -.theme-black .tpl-form-line-form input[type=time], -.theme-black .tpl-form-line-form input[type=week], -.theme-black .tpl-form-line-form input[type=email], -.theme-black .tpl-form-line-form input[type=url], -.theme-black .tpl-form-line-form input[type=tel], -.theme-black .tpl-form-line-form input[type=color], -.theme-black .tpl-form-line-form select, -.theme-black .tpl-form-line-form textarea, -.theme-black .am-form-field { - display: block; - width: 100%; - padding: 6px 12px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border-bottom: 1px solid rgba(255, 255, 255, 0.2); - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #fff; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} -.theme-black .tpl-form-line-form .am-checkbox, -.theme-black .tpl-form-line-form .am-checkbox-inline, -.theme-black .tpl-form-line-form .am-form-label, -.theme-black .tpl-form-line-form .am-radio, -.theme-black .tpl-form-line-form .am-radio-inline { - margin-top: 0; - margin-bottom: 0; -} -.theme-black .tpl-form-line-form .am-form-group:after { - clear: both; -} -.theme-black .tpl-form-line-form .am-form-group:after, -.theme-black .tpl-form-line-form .am-form-group:before { - content: " "; - display: table; -} -.theme-black .tpl-form-line-form .am-form-label { - padding-top: 5px; - font-size: 16px; - color: #fff; - font-weight: inherit; - text-align: right; -} -.theme-black .tpl-form-line-form .am-form-group { - /*padding: 20px 0;*/ -} -.theme-black .tpl-form-line-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} -.theme-black .tpl-table-black-operation a { - border: 1px solid #7b878d; - color: #7b878d; -} -.theme-black .tpl-table-black-operation a:hover { - background: #7b878d; - color: #fff; -} -.theme-black .tpl-table-black-operation a.tpl-table-black-operation-del { - border: 1px solid #f35842; - color: #f35842; -} -.theme-black .tpl-table-black-operation a.tpl-table-black-operation-del:hover { - background: #f35842; - color: #fff; -} -.theme-black .am-table-bordered { - border: 1px solid #666d70; -} -.theme-black .am-table-bordered > tbody > tr > td, -.theme-black .am-table-bordered > tbody > tr > th, -.theme-black .am-table-bordered > tfoot > tr > td, -.theme-black .am-table-bordered > tfoot > tr > th, -.theme-black .am-table-bordered > thead > tr > td, -.theme-black .am-table-bordered > thead > tr > th { - border: 1px solid #666d70; -} -.theme-black .am-table-bordered > thead + tbody > tr:first-child > td, -.theme-black .am-table-bordered > thead + tbody > tr:first-child > th { - border: 1px solid #666d70; -} -.theme-black .am-table-striped > tbody > tr:nth-child(odd) > td, -.theme-black .am-table-striped > tbody > tr:nth-child(odd) > th { - background-color: #5d6468; -} -.theme-black .tpl-table-black { - color: #fff; -} -.theme-black .tpl-table-black thead > tr > th { - font-size: 14px; - padding: 6px; - border-bottom: 1px solid #666d70; -} -.theme-black .tpl-table-black tbody > tr > td { - font-size: 14px; - padding: 7px 6px; - border-top: 1px solid #666d70; -} -.theme-black .tpl-table-black tfoot > tr > th { - font-size: 14px; - padding: 6px 0; -} -.theme-black .tpl-user-card { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; -} -.theme-black .tpl-user-card-title { - font-size: 26px; - margin-top: 0; - font-weight: 300; - margin-top: 25px; - margin-bottom: 10px; -} -.theme-black .achievement-subheading { - font-size: 12px; - margin-top: 0; - margin-bottom: 15px; -} -.theme-black .achievement-image { - border-radius: 50%; - margin-bottom: 22px; -} -.theme-black .achievement-description { - margin: 0; - font-size: 12px; -} -.theme-black .am-progress { - height: 12px; - margin-bottom: 14px; - background: rgba(0, 0, 0, 0.15); -} -.theme-black .am-progress-title { - font-size: 14px; - margin-bottom: 8px; -} -.theme-black .am-progress-title-more { - color: #a1a8ab; -} -.theme-black .widget-fluctuation-tpl-btn { - margin-top: 6px; - display: block; - color: #fff; - font-size: 12px; - padding: 5px 10px; - outline: none; - background-color: rgba(255, 255, 255, 0); - border: 1px solid #fff; -} -.theme-black .widget-fluctuation-tpl-btn:hover { - background: #fff; - color: #4b5357; -} -.theme-black .widget-fluctuation-description-text { - color: #c5cacd; -} -.theme-black .text-success { - color: #08ed72; -} -.theme-black .widget-fluctuation-period-text { - color: #fff; -} -.theme-black .widget-head { - border-bottom: 1px solid #3f4649; -} -.theme-black .widget-function a { - color: #7b878d; -} -.theme-black .widget-function a:hover { - color: #fff; -} -.theme-black .widget { - border: 1px solid #33393c; - border-top: 2px solid #313639; - background: #4b5357; - color: #ffffff; -} -.theme-black .widget-primary { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; - padding: 12px 17px; -} -.theme-black .widget-statistic-icon { - position: absolute; - z-index: 30; - right: 30px; - top: 0px; - font-size: 70px; - color: #1b9eca; -} -.theme-black .widget-statistic-description { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - line-height: 14px; - padding-top: 8px; - color: #9cdcf2; -} -.theme-black .widget-statistic-value { - position: relative; - z-index: 35; - font-weight: 300; - display: block; - color: #fff; - font-size: 46px; - line-height: 46px; - margin-bottom: 8px; -} -.theme-black .widget-statistic-header { - color: #9cdcf2; -} -.theme-black .widget-purple { - padding: 12px 17px; - border: 1px solid #5e4578; - border-top: 2px solid #5c4375; - background: #785799; - color: #ffffff; -} -.theme-black .widget-purple .widget-statistic-icon { - color: #8a6aaa; -} -.theme-black .widget-purple .widget-statistic-header { - color: #ded5e7; -} -.theme-black .widget-purple .widget-statistic-description { - color: #ded5e7; -} -.theme-black .page-header-description { - color: #e6e6e6; -} -.theme-black .page-header-heading { - color: #666; -} -.theme-black .container-fluid { - background: #424b4f; -} -.theme-black .page-header-heading { - color: #fff; -} -.theme-black .sidebar-nav-heading { - color: #fff; -} -.theme-black .tpl-sidebar-user-panel { - background: #1f2224; - border-bottom: 1px solid #1f2224; -} -.theme-black .tpl-content-wrapper { - background: #3a4144; -} -.theme-black .tpl-header-fluid { - background: #2f3638; -} -.theme-black .sidebar-nav-link a.active { - background: #232829; -} -.theme-black .sidebar-nav-link a:hover { - background: #232829; -} -.theme-black .tpl-header-switch-button { - background: #2f3638; - border-right: 1px solid #282d2f; -} -.theme-black .tpl-header-switch-button:hover { - background: #282d2f; - color: #fff; -} -.theme-black .tpl-header-navbar a { - color: #cfcfcf; -} -.theme-black .tpl-header-navbar a:hover { - color: #fff; -} -.theme-black .left-sidebar { - padding-top: 56px; - background: #282d2f; -} -.theme-black .widget-color-green { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; -} -.theme-black .widget-color-green .widget-head { - border-bottom: 1px solid #147494; -} -.theme-black .widget-color-green .widget-fluctuation-description-text { - color: #bbe7f6; -} -.theme-black .widget-color-green .widget-function a { - color: #42bde5; -} -.theme-black .widget-color-green .widget-function a:hover { - color: #fff; -} -@media screen and (max-width: 1024px) { - .tpl-index-settings-button { - display: none; - } - .theme-black .left-sidebar { - padding-top: 111px; - } - .left-sidebar { - padding-top: 111px; - } - .tpl-content-wrapper { - margin-left: 0; - } - .tpl-header-logo { - float: none; - width: 100%; - } - .tpl-header-navbar-welcome { - display: none; - } - .tpl-sidebar-user-panel { - border-top: 1px solid #eee; - } - .tpl-header-fluid { - border-top: none; - margin-left: 0; - } - .theme-white .tpl-header-fluid { - border-top: none; - } - .theme-black .tpl-sidebar-user-panel { - border-top: 1px solid #1f2224; - } -} -@media screen and (min-width: 641px) { - [class*=am-u-] { - padding-left: 10px; - padding-right: 10px; - } -} -@media screen and (max-width: 641px) { - .theme-white .tpl-error-title, - .theme-black .tpl-error-title { - font-size: 130px; - line-height: 140px; - } - .theme-white .tpl-login-title { - font-size: 20px; - } - .theme-white .tpl-login-content { - width: 86%; - padding: 22px 30px 25px; - } - .tpl-header-search { - display: none; - } - ul.tpl-dropdown-content { - position: fixed; - width: 100%; - left: 0; - top: 112px; - right: 0; - } -} diff --git a/Day61-65/code/project_of_tornado/assets/css/app.less b/Day61-65/code/project_of_tornado/assets/css/app.less deleted file mode 100644 index 1b8de9a..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/app.less +++ /dev/null @@ -1,2056 +0,0 @@ -ul,li { - list-style: none; - padding: 0; - margin: 0; -} - -a { - -} - -header { - z-index: 1200; - position: relative; -} -.tpl-header-logo { - width: 240px; - height: 57px; - display: table; - text-align:center; - position: relative; - z-index: 1300; - - a { - display:table-cell; - vertical-align:middle; - } - - img { - width:170px; - } -} - - -.tpl-header-fluid { - margin-left: 240px; - height: 56px; - - padding-left: 20px; - padding-right: 20px; -} - - -.tpl-header-switch-button { - - margin-top: 0px; - margin-bottom: 0px; - float: left; - color: #cfcfcf; - margin-left: -20px; - margin-right: 0; - border: 0; - border-radius: 0; - padding: 0px 22px; - font-size: 22px; - line-height: 55px; - - &:hover { - - outline: none; - } -} - - -.tpl-header-search-form { - height: 54px; - line-height: 52px; - margin-left: 10px; - -} -.tpl-header-search-box , .tpl-header-search-btn { - transition: all 0.4s ease-in-out; - color: #848c90; - background: none; - border: none; - outline: none; -} - -.tpl-header-search-box { - font-size: 14px; - - &:hover,&:active { - color: #fff; - } -} - -.tpl-header-search-btn { - font-size: 15px; - - &:hover,&:active { - color: #fff; - } -} - -.tpl-header-navbar { - color: #fff; - li { - float: left; - } - a { - line-height: 56px; - display: block; - padding: 0 16px; - position: relative; - - - &:hover { - - } - - .item-feed-badge { - position: absolute; - top: 9px; - left: 25px; - } - } -} - -ul.tpl-dropdown-content { - padding: 10px; - margin-top: 0; - width: 300px; - background-color: #2f3638; - border: 1px solid #525e62; - border-radius: 0; - - li { - float:none; - } - - &:before , &:after { - display: none; - } -} - - -ul.tpl-dropdown-content { - - - .tpl-dropdown-menu-notifications { - - } - - .tpl-dropdown-menu-notifications-title { - font-size: 12px; - float: left; - color: rgba(255, 255, 255, 0.7); - } - - .tpl-dropdown-menu-notifications-time { - float: right; - text-align: right; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; - width: 50px; - margin-left: 10px; - } - - .tpl-dropdown-menu-notifications:last-child .tpl-dropdown-menu-notifications-item { - text-align: center; - border: none; - font-size: 12px; - i { - margin-left: -6px; - } - } - - .tpl-dropdown-menu-messages:last-child .tpl-dropdown-menu-messages-item { - text-align: center; - border: none; - font-size: 12px; - i { - margin-left: -6px; - } - } - .tpl-dropdown-menu-notifications-item , .tpl-dropdown-menu-messages-item { - padding: 12px; - color: #fff; - line-height: 20px; - border-bottom: 1px solid rgba(255, 255, 255, 0.15); - - &:hover , &:focus { - background-color: #465154; - color: #fff; - } - - - - .menu-messages-ico { - line-height: initial; - float: left; - width: 35px; - height: 35px; - border-radius: 50%; - margin-right: 10px; - margin-top: 6px; - overflow: hidden; - - img { - width: 100%; - height: auto; - vertical-align: middle; - } - } - - .menu-messages-time { - float: right; - text-align: right; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; - width: 40px; - margin-left: 10px; - - - } - - .menu-messages-content { - display: block; - font-size: 13px; - margin-left: 45px; - margin-right: 50px; - - .menu-messages-content-title { - - } - - .menu-messages-content-time { - margin-top: 3px; - color: rgba(255, 255, 255, 0.7); - font-size: 11px; - } - } - - - } -} - -.am-dimmer { - z-index: 1200; -} -.am-modal { - z-index: 1300; -} -.am-datepicker-dropdown { - z-index: 1400; -} - -.tpl-skiner { - transition: all 0.4s ease-in-out; - position: fixed; - z-index: 10000; - right: -130px; - top: 65px; -} - -.tpl-skiner.active { - right: 0px; -} -.tpl-skiner-content { - background: rgba(0, 0, 0, 0.7); - width: 130px; - padding: 15px; - border-radius: 4px 0 0 4px; - overflow: hidden; -} - -.fc-content .am-icon-close { - position: absolute; - right: 0; - top: 0px; -} -.tpl-skiner-toggle { - position: absolute; - top: 5px; - left: -40px; - width: 40px; - color:#969a9b; - font-size: 20px; - height: 40px; - line-height: 40px; - text-align: center; - background: rgba(0, 0, 0, 0.7); - cursor: pointer; - border-top-left-radius: 4px; - border-bottom-left-radius: 4px; - -} -.tpl-skiner-content-title { - margin: 0; - margin-bottom: 4px; - padding-bottom: 4px; - font-size: 16px; - text-transform: uppercase; - color:#fff; - border-bottom: 1px solid rgba(255, 255, 255, 0.3); -} - -.tpl-skiner-content-bar { - padding-top: 10px; - .skiner-color { - transition: all 0.4s ease-in-out; - float: left; - width: 25px; - height: 25px; - margin-right: 10px; - cursor: pointer; - } - .skiner-white { - background: #fff; - border: 2px solid #eee; - } - - .skiner-black { - background: #000; - border: 2px solid #222; - } -} - -.sub-active { - color:#fff!important; -} -.left-sidebar { - transition: all 0.4s ease-in-out; - width: 240px; - min-height: 100%; - padding-top: 57px; - position: absolute; - z-index: 1104; - top: 0; - left: 0px; - &.xs-active { - left:0px; - } - &.active { - left:-240px; - } - -} -.tpl-sidebar-user-panel { - padding: 22px; - padding-top: 28px; -} - -.tpl-user-panel-slide-toggleable { - -} - -.tpl-user-panel-profile-picture { - border-radius: 50%; - width: 82px; - height: 82px; - margin-bottom: 10px; - overflow: hidden; - - img { - width: auto; - height: 82px; - vertical-align: middle; - } -} -.tpl-user-panel-status-icon { - margin-right: 2px; -} -.user-panel-logged-in-text { - display: block; - - color:#cfcfcf; - font-size: 14px; -} -.tpl-user-panel-action-link { - color: #6d787c; - font-size: 12px; - &:hover { - color: #a2aaad; - } -} - -.sidebar-nav { - list-style-type: none; - padding: 0; - margin: 0; -} - -.sidebar-nav-sub { - display: none; - .sidebar-nav-link { - font-size: 12px; - padding-left: 30px; - a { - font-size: 12px; - padding-left: 0; - } - } - - .sidebar-nav-link-logo { - margin-right: 8px; - width: 20px; - font-size: 16px; - } -} - -.sidebar-nav-sub-ico-rotate{ - -webkit-transform: rotate(180deg); - transform: rotate(180deg); - -webkit-transition: all 300ms; - transition: all 300ms; -} -.sidebar-nav-link-logo-ico { - margin-top: 5px; -} -.sidebar-nav-heading { - padding: 24px 17px; - font-size: 15px; - font-weight: 500; -} -.sidebar-nav-heading-info { - font-size: 12px; - color:#868E8E; - padding-left: 10px; -} -.sidebar-nav-link-logo { - margin-right: 8px; - width: 20px; - font-size: 16px; -} -.sidebar-nav-link { - - color: #fff; - - a { - display: block; - color: #868E8E; - padding: 10px 17px; - border-left: #282d2f 3px solid; - font-size: 14px; - cursor: pointer; - - &.active { - cursor: pointer; - border-left: #1CA2CE 3px solid; - color: #fff; - - } - - &:hover { - color: #fff; - } - } -} - -.tpl-content-wrapper { - transition: all 0.4s ease-in-out; - position: relative; - margin-left: 240px; - z-index: 1101; - min-height: 922px; - border-bottom-left-radius: 3px; - &.xs-active { - margin-left: 240px; - } - &.active { - margin-left: 0; - } -} - -.page-header { - background: #424b4f; - margin-top: 0; - margin-bottom: 0; - padding: 40px 0; - border-bottom: 0; -} - -.container-fluid { - margin-top: 0; - margin-bottom: 0; - padding: 40px 0; - border-bottom: 0; - padding-left: 20px; - padding-right: 20px; -} - -.row { - margin-right: -10px; - margin-left: -10px; -} - -.page-header-description { - margin-top: 4px; - margin-bottom: 0; - font-size: 14px; - color: #e6e6e6; -} -.page-header-heading { - font-size: 20px; - font-weight: 400; - .page-header-heading-ico { - font-size: 28px; - position: relative; - top: 3px; - } - small { - font-weight: normal; - line-height: 1; - color: #B3B3B3; - } -} - -.page-header-button { - transition: all 0.4s ease-in-out; - opacity: 0.3; - font-weight: 500; - border-radius: 0; - float: right; - outline: none; - border: 1px solid #fff; - padding: 16px 36px; - font-size: 23px; - line-height: 23px; - border-radius: 0; - padding-top: 14px; - color: #fff; - background-color: rgba(0, 0, 0, 0); - font-weight: 500; - - &:hover { - background-color: #ffffff; - color: #333; - opacity: 1; - } -} -.widget { - width: 100%; - min-height: 148px; - margin-bottom: 20px; - border-radius: 0; - position: relative; -} - -.widget-head { - width: 100%; - padding: 15px; -} - -.widget-title { - font-size: 14px; -} -.widget-function { - -} -.widget-fluctuation-period-text { - display: inline-block; - font-size: 16px; - line-height: 20px; - margin-bottom: 9px; -} -.widget-body { - padding: 13px 15px; - width: 100%; -} -.row-content { - padding: 20px; -} - -.widget-fluctuation-description-text{ -margin-top: 4px; - display: block; - font-size: 12px; - line-height: 13px; - } - -.text-success { - -} -.widget-fluctuation-tpl-btn { - -} -.widget-fluctuation-description-amount { - display: block; - font-size: 20px; - line-height: 22px; -} - -.widget-primary { - -} - -.widget-statistic-header { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - text-transform: uppercase; - margin-bottom: 8px; -} - .widget-body-md { - height: 200px; - } -.widget-body-lg { - min-height: 330px; - // height: 330px; -} -.widget-margin-bottom-lg { - margin-bottom: 20px; -} - -.tpl-table-black-operation { - -} - - -.tpl-table-black-operation { - a { - display: inline-block; - padding: 5px 6px; - font-size: 12px; - line-height: 12px; - } -} -.tpl-switch input[type="checkbox"] { - position: absolute; - opacity: 0; - width: 50px; - height: 20px; - } - - - .tpl-switch input[type="checkbox"].ios-switch + div { - vertical-align: middle; - width: 40px; - height: 20px; - - border-radius: 999px; - background-color: rgba(0, 0, 0, 0.1); - -webkit-transition-duration: .4s; - -webkit-transition-property: background-color, box-shadow; - - margin-top: 6px; - } - - - .tpl-switch input[type="checkbox"].ios-switch:checked + div { - width: 40px; - background-position: 0 0; - background-color: #36c6d3; - - - } - - - .tpl-switch input[type="checkbox"].tinyswitch.ios-switch + div { - width: 34px; - height: 18px; - } - - - .tpl-switch input[type="checkbox"].bigswitch.ios-switch + div { - width: 50px; - height: 25px; - } - - - .tpl-switch input[type="checkbox"].green.ios-switch:checked + div { - background-color: #00e359; - border: 1px solid rgba(0, 162, 63, 1); - box-shadow: inset 0 0 0 10px rgba(0, 227, 89, 1); - } - - - .tpl-switch input[type="checkbox"].ios-switch + div > div { - float: left; - width: 18px; - height: 18px; - border-radius: inherit; - background: #ffffff; - -webkit-transition-timing-function: cubic-bezier(.54, 1.85, .5, 1); - -webkit-transition-duration: 0.4s; - -webkit-transition-property: transform, background-color, box-shadow; - -moz-transition-timing-function: cubic-bezier(.54, 1.85, .5, 1); - -moz-transition-duration: 0.4s; - -moz-transition-property: transform, background-color; - - pointer-events: none; - margin-top: 1px; - margin-left: 1px; - } - - - .tpl-switch input[type="checkbox"].ios-switch:checked + div > div { - -webkit-transform: translate3d(20px, 0, 0); - -moz-transform: translate3d(20px, 0, 0); - background-color: #ffffff; - - } - - - .tpl-switch input[type="checkbox"].tinyswitch.ios-switch + div > div { - width: 16px; - height: 16px; - margin-top: 1px; - } - - - .tpl-switch input[type="checkbox"].tinyswitch.ios-switch:checked + div > div { - -webkit-transform: translate3d(16px, 0, 0); - -moz-transform: translate3d(16px, 0, 0); - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0px 0px 0 1px rgba(8, 80, 172, 1); - } - - - .tpl-switch input[type="checkbox"].bigswitch.ios-switch + div > div { - width: 23px; - height: 23px; - margin-top: 1px; - } - - - .tpl-switch input[type="checkbox"].bigswitch.ios-switch:checked + div > div { - -webkit-transform: translate3d(25px, 0, 0); - -moz-transform: translate3d(16px, 0, 0); - - } - - - .tpl-switch input[type="checkbox"].green.ios-switch:checked + div > div { - box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 162, 63, 1); - } - - - -.tpl-page-state { - width: 100%; -} - -.tpl-page-state-title { - font-size: 40px; - font-weight: bold; -} - -.tpl-page-state-content { - padding: 10px 0; -} - -.tpl-login { - width: 100%; -} - -.tpl-login-logo { - max-width: 159px; - height: 205px; - margin: 0 auto; - margin-bottom: 20px; -} -.tpl-login-title { - width: 100%; - font-size: 24px; -} -.tpl-login-content { - width: 300px; - margin: 12% auto 0; -} -.tpl-login-remember-me { - color: #B3B3B3; - font-size: 14px; - - label { - position: relative; - top: -2px; - } -} -.tpl-login-content-info { - color: #B3B3B3; - font-size: 14px; -} - -.tpl-pagination { - -} - -.cl-p { - padding: 0!important; -} -.tpl-table-line-img { - max-width: 100px; - padding: 2px; -} -.tpl-table-list-select { - text-align:right; - } -.fc-button-group, .fc button { - display: block; -} - -.theme-white { - - .sidebar-nav-sub { - .sidebar-nav-link-logo { - margin-left: 10px; - } - } - .tpl-header-search-box:hover, .tpl-header-search-box:active - .tpl-error-title { - - color: #848c90; - } - .tpl-error-title-info { - line-height: 30px; - font-size: 21px; - margin-top: 20px; - text-align: center; - color: #dce2ec; - } - .tpl-error-btn { - background: #03a9f3; - border: 1px solid #03a9f3; - border-radius: 30px; - padding: 6px 20px 8px; - } - .tpl-error-content { - margin-top: 20px; - margin-bottom: 20px; - font-size: 16px; - text-align: center; - color: #96a2b4; - } -.tpl-calendar-box { - background: #fff; - border-radius: 4px; - padding: 20px; - .fc-event { - border-radius: 0; - background: #03a9f3; - border: 1px solid #14b0f6; - } - .fc-axis { - color: #868E8E; - } - .fc-unthemed .fc-today { - background: #eee; - } - .fc-more { - color: #868E8E; - } - - .fc th.fc-widget-header { - background: #32c5d2!important; - - color: #ffffff; - font-size: 14px; - line-height: 20px; - padding: 7px 0px; - text-transform: uppercase; - border:none!important; - a { - color: #fff; - } - } - - .fc-center { - h2 { - color:#868E8E; - } - } - .fc-state-default { - background-image: none; - background: #fff; - font-size: 14px; - color: #868E8E; -} - .fc th, .fc td, .fc hr, .fc thead, .fc tbody, .fc-row { - // background: rgba(0, 0, 0, 0)!important; - border-color: #eee!important; - } - .fc-day-number { - color: #868E8E; - padding-right: 6px; - } - .fc th { - color: #868E8E; - font-weight: normal; - font-size: 14px; - padding: 6px 0; - } - } - - .tpl-login-logo { - background: url(../img/logoa.png) center no-repeat; - - } - .sub-active { - - color:#23abf0!important; - } -.tpl-table-line-img { - border: 1px solid #ddd; -} -.tpl-pagination .am-disabled a , .tpl-pagination li a { - color: #23abf0; - border-radius: 3px; - padding: 6px 12px; -} - -.tpl-pagination .am-active a{ - background: #23abf0;color: #fff; - border: 1px solid #23abf0; - padding: 6px 12px; -} - - -.tpl-login-btn { - background-color:#32c5d2; - border: none; - padding: 10px 16px; - font-size: 14px; - line-height: 14px; - outline: none; - - &:hover,&:active { - background: #22b2e1; - color:#fff; - } - -} -.tpl-login-title { - color: #697882; - strong { - color: #39bae4; - } -} - .tpl-login-content{ - width: 500px; - padding: 40px 40px 25px; - background-color: #fff; - border-radius: 4px; - } - - .tpl-form-line-form , .tpl-form-border-form { - padding-top: 20px; - } - - -.tpl-form-border-form input[type=number]:focus, .tpl-form-border-form input[type=search]:focus, .tpl-form-border-form input[type=text]:focus, .tpl-form-border-form input[type=password]:focus, .tpl-form-border-form input[type=datetime]:focus, .tpl-form-border-form input[type=datetime-local]:focus, .tpl-form-border-form input[type=date]:focus, .tpl-form-border-form input[type=month]:focus, .tpl-form-border-form input[type=time]:focus, .tpl-form-border-form input[type=week]:focus, .tpl-form-border-form input[type=email]:focus, .tpl-form-border-form input[type=url]:focus, .tpl-form-border-form input[type=tel]:focus, .tpl-form-border-form input[type=color]:focus, .tpl-form-border-form select:focus, .tpl-form-border-form textarea:focus, .am-form-field:focus{ - -webkit-box-shadow: none; - box-shadow: none; - } -.tpl-form-border-form input[type=number], .tpl-form-border-form input[type=search], .tpl-form-border-form input[type=text], .tpl-form-border-form input[type=password], .tpl-form-border-form input[type=datetime], .tpl-form-border-form input[type=datetime-local], .tpl-form-border-form input[type=date], .tpl-form-border-form input[type=month], .tpl-form-border-form input[type=time], .tpl-form-border-form input[type=week], .tpl-form-border-form input[type=email], .tpl-form-border-form input[type=url], .tpl-form-border-form input[type=tel], .tpl-form-border-form input[type=color], .tpl-form-border-form select, .tpl-form-border-form textarea, .am-form-field { - display: block; - width: 100%; - - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - -webkit-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border: 1px solid #c2cad8; - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - text-indent: .5em; - -o-border-radius: 0; - border-radius: 0; - color: #555; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} - -.tpl-form-border-form .am-checkbox, .tpl-form-border-form .am-checkbox-inline, .tpl-form-border-form .am-form-label, .tpl-form-border-form .am-radio, .tpl-form-border-form .am-radio-inline{ - margin-top: 0; - margin-bottom: 0; - -} - -.tpl-form-border-form .am-form-group:after { - clear: both; -} -.tpl-form-border-form .am-form-group:after, .tpl-form-border-form .am-form-group:before { -content: " "; - display: table; - -} -.tpl-form-border-form .am-form-label{ - padding-top: 5px; -font-size: 16px; -color: #888; -font-weight: inherit; -text-align: right; -} -.tpl-form-border-form .am-form-group { - /*padding: 20px 0;*/ - -} -.tpl-form-border-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} - - .tpl-form-line-form input[type=number]:focus, .tpl-form-line-form input[type=search]:focus, .tpl-form-line-form input[type=text]:focus, .tpl-form-line-form input[type=password]:focus, .tpl-form-line-form input[type=datetime]:focus, .tpl-form-line-form input[type=datetime-local]:focus, .tpl-form-line-form input[type=date]:focus, .tpl-form-line-form input[type=month]:focus, .tpl-form-line-form input[type=time]:focus, .tpl-form-line-form input[type=week]:focus, .tpl-form-line-form input[type=email]:focus, .tpl-form-line-form input[type=url]:focus, .tpl-form-line-form input[type=tel]:focus, .tpl-form-line-form input[type=color]:focus, .tpl-form-line-form select:focus, .tpl-form-line-form textarea:focus, .am-form-field:focus{ - -webkit-box-shadow: none; - box-shadow: none; - } -.tpl-form-line-form input[type=number], .tpl-form-line-form input[type=search], .tpl-form-line-form input[type=text], .tpl-form-line-form input[type=password], .tpl-form-line-form input[type=datetime], .tpl-form-line-form input[type=datetime-local], .tpl-form-line-form input[type=date], .tpl-form-line-form input[type=month], .tpl-form-line-form input[type=time], .tpl-form-line-form input[type=week], .tpl-form-line-form input[type=email], .tpl-form-line-form input[type=url], .tpl-form-line-form input[type=tel], .tpl-form-line-form input[type=color], .tpl-form-line-form select, .tpl-form-line-form textarea, .am-form-field { - display: block; - width: 100%; - - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - -webkit-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border-bottom: 1px solid #c2cad8; - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #555; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} - -.tpl-form-line-form .am-checkbox, .tpl-form-line-form .am-checkbox-inline, .tpl-form-line-form .am-form-label, .tpl-form-line-form .am-radio, .tpl-form-line-form .am-radio-inline{ - margin-top: 0; - margin-bottom: 0; - -} - -.tpl-form-line-form .am-form-group:after { - clear: both; -} -.tpl-form-line-form .am-form-group:after, .tpl-form-line-form .am-form-group:before { -content: " "; - display: table; - -} -.tpl-form-line-form .am-form-label{ - padding-top: 5px; -font-size: 16px; -color: #888; -font-weight: inherit; -text-align: right; -} -.tpl-form-line-form .am-form-group { - /*padding: 20px 0;*/ - -} -.tpl-form-line-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} - - .tpl-table-black-operation { - a { - border: 1px solid #36c6d3; - color:#36c6d3; - &:hover { - background: #36c6d3; - color:#fff; - } - } - a.tpl-table-black-operation-del { - border: 1px solid #e7505a; - color:#e7505a; - &:hover { - background: #e7505a; - color:#fff; - } - } -} - .tpl-amendment-echarts { - left: -17px; - } - .tpl-user-card { - border: 1px solid #3598dc; - border-top: 2px solid #3598dc; - background: #3598dc; - color: #ffffff; - border-radius: 4px; - } - .tpl-user-card-title { - font-size: 26px; - margin-top: 0; - font-weight: 300; - margin-top: 25px; - margin-bottom: 10px; - } - .achievement-subheading { - font-size: 12px; - margin-top: 0; - margin-bottom: 15px; - } - .achievement-image { - border-radius: 50%; - margin-bottom: 22px; - } - .achievement-description { - margin: 0; - font-size: 12px; - } - - .tpl-table-black { - color: #838FA1; - - thead>tr>th { - font-size: 14px; - padding: 6px; - } - tbody>tr>td { - font-size: 14px; - padding: 7px 6px; - - } - tfoot>tr>th { - font-size: 14px; - padding: 6px 0; - } - } - - - .am-progress { - height: 12px; - } - .am-progress-title { - font-size: 14px; - margin-bottom: 8px; - } - .am-progress-title-more { - - } - .widget-fluctuation-tpl-btn { - margin-top: 6px; - display: block; - color: #fff; - font-size: 12px; - padding: 8px 14px; - outline: none; - background-color: #e7505a; - border: 1px solid #e7505a; - &:hover { - background:transparent; - color:#e7505a; - } - - } - .widget-fluctuation-description-text{ -color: #c5cacd; - } - background: #e9ecf3; - .widget-fluctuation-period-text { - color:#838FA1; - } -.text-success { - color: #5eb95e; -} - .widget-head { - border-bottom: 1px solid #eef1f5; -} - .widget-function { - a { - color: #838FA1; - &:hover { - color:#a7bdcd; - } - } - - } - .widget { - padding: 10px 20px 13px; - background-color: #fff; - border-radius: 4px; - color: #838FA1; - - } - .widget-title { - font-size: 16px; - } - - .widget-primary { - - min-height: 174px; - border: 1px solid #32c5d2; - border-top: 2px solid #32c5d2; - background: #32c5d2; - color: #ffffff; - padding: 12px 17px; - padding-left: 22px; -} -.widget-statistic-body { - -} -.widget-statistic-icon { - position: absolute; - z-index: 30; - right: 30px; - top: 24px; - font-size: 70px; - color: #46cad6; -} -.widget-statistic-description { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - line-height: 14px; - padding-top: 8px; - color: #fff; -} -.widget-statistic-value { - position: relative; - z-index: 35; - font-weight: 300; - display: block; - color: #fff; - font-size: 46px; - line-height: 46px; - margin-bottom: 8px; -} -.widget-statistic-header { - padding-top: 18px; - color: #fff; -} -.widget-purple { - padding: 12px 17px; - border: 1px solid #8E44AD; - border-top: 2px solid #8E44AD; - background: #8E44AD; - color: #ffffff; - min-height: 174px; - .widget-statistic-icon { - color: #9956b5; - } - .widget-statistic-header { - color: #ded5e7; - } - .widget-statistic-description { - color: #ded5e7; - } -} - .page-header-button { - opacity: .8; - border: 1px solid #32c5d2; - background: #32c5d2; - color:#fff; - &:hover { - opacity: 1; - } - } - .page-header-description { - color: #666; - } - .page-header-heading { - color: #666; - } - .container-fluid { - - } - ul.tpl-dropdown-content .tpl-dropdown-menu-messages-item .menu-messages-content .menu-messages-content-time { - color: #96a5aa; - } - ul.tpl-dropdown-content { - background: #fff; - border: 1px solid #ddd; - .tpl-dropdown-menu-notifications-item , .tpl-dropdown-menu-messages-item { - border-bottom: 1px solid #eee; - color:#999; - - &:hover{ - background-color: #f5f5f5; - } - .tpl-dropdown-menu-notifications-time { - color: #999; - } - } - .tpl-dropdown-menu-messages-item:hover { - background-color: #f5f5f5; - } - - .tpl-dropdown-menu-notifications-title { - color:#999; - } - - - } - .sidebar-nav-link { - a { - border-left: #fff 3px solid; - } - a:hover { - - background: #f2f6f9; - color: #868E8E; - border-left: #3bb4f2 3px solid; - } - } - - .sidebar-nav-link a.active { - background: #f2f6f9; - color: #868E8E; - border-left: #3bb4f2 3px solid; - } - .sidebar-nav-heading { - color: #999; - border-bottom: 1px solid #eee; - } - .tpl-sidebar-user-panel { - background: #fff; - border-bottom: 1px solid #eee; - } -.tpl-content-wrapper { - background: #e9ecf3; - } - .tpl-header-fluid { - background: #fff; - border-top: 1px solid #eee; -} - .tpl-header-logo { - background: #fff; - border-bottom: 1px solid #eee; -} - -.tpl-header-switch-button { - background: #fff; - border-right: 1px solid #eee; - border-left: 1px solid #eee; - &:hover { - background: #fff; - color: #999; - } -} - .tpl-header-navbar { - a { - color:#999; - - &:hover { - color: #999; - } - } - } - .left-sidebar { - background: #fff; - } - - .widget-color-green { - border: 1px solid #32c5d2; - border-top: 2px solid #32c5d2; - background: #32c5d2; - color: #ffffff; - .widget-fluctuation-period-text { - color:#fff; - } - .widget-head { - border-bottom: 1px solid #2bb8c4; - } - .widget-fluctuation-description-text { - color:#bbe7f6; - } - .widget-function { - a { - color:#42bde5; - &:hover { - color: #fff; - } - } - } - } - - - -} - - -.theme-black { - - .tpl-am-model-bd { - background: #424b4f; - } - .tpl-model-dialog { - background: #424b4f; - } - .tpl-error-title { - font-size: 210px; - line-height: 220px; - color: #868E8E; - } - .tpl-error-title-info { - line-height: 30px; - font-size: 21px; - margin-top: 20px; - text-align: center; - color: #868E8E; - } - .tpl-error-btn { - background: #03a9f3; - border: 1px solid #03a9f3; - border-radius: 30px; - padding: 6px 20px 8px; - } - .tpl-error-content { - margin-top: 20px; - margin-bottom: 20px; - font-size: 16px; - text-align: center; - color: #cfcfcf; - } - .tpl-calendar-box { - background: #424b4f; - padding: 20px; - .fc-button { - border-radius: 0; - box-shadow:0; - } - .fc-event { - border-radius: 0; - background: #03a9f3; - } - .fc-axis { - color: #fff; - } - .fc-unthemed .fc-today { - background: #3a4144; - } - .fc-more { - color: #fff; - } - .fc th.fc-widget-header { - background: #9675ce!important; - color: #ffffff; - font-size: 14px; - line-height: 20px; - padding: 7px 0px; - text-transform: uppercase; - border:none!important; - a { - color: #fff; - } - } - - .fc-center { - h2 { - color:#fff; - } - } - .fc-state-default { - background-image: none; - background: #fff; - font-size: 14px; -} - .fc th, .fc td, .fc hr, .fc thead, .fc tbody, .fc-row { - // background: rgba(0, 0, 0, 0)!important; - border-color: rgba(120, 130, 140, 0.4) !important; - } - .fc-day-number { - color: #868E8E; - padding-right: 6px; - } - .fc th { - color: #868E8E; - font-weight: normal; - font-size: 14px; - padding: 6px 0; - } - } - .tpl-login-logo { - background: url(../img/logob.png) center no-repeat; - - } - .tpl-table-line-img { - max-width: 100px; - padding: 2px; -border: none; -} - .tpl-table-list-field { - border: none; - } - .tpl-table-list-select { - - .am-dropdown-content { - color:#888; - } - .am-selected-btn { - border:1px solid rgba(255, 255, 255, 0.2); - color:#fff; - } - - .am-btn-default.am-active, .am-btn-default:active, .am-dropdown.am-active .am-btn-default.am-dropdown-toggle { - border:1px solid rgba(255, 255, 255, 0.2); - color:#fff; - background: #5d6468; - } - } -.tpl-pagination .am-disabled a , .tpl-pagination li a { - color: #fff; - padding: 6px 12px; - background: #3f4649; - border: none; -} - -.tpl-pagination .am-active a{ - background: #167fa1;color: #fff; - border: 1px solid #167fa1; - padding: 6px 12px; -} - -.tpl-login-btn { - border: 1px solid #b5b5b5; - background-color: rgba(0, 0, 0, 0); - padding: 10px 16px; - font-size: 14px; - line-height: 14px; - color:#b5b5b5; - - &:hover,&:active { - background: #b5b5b5; - color:#fff; - } - -} -.tpl-login-title { - color:#fff; - strong { - color: #39bae4; - } -} - - - - - .tpl-form-line-form , .tpl-form-border-form { - padding-top: 20px; - - .am-btn-default { - color:#fff; - border: 1px solid rgba(255, 255, 255, 0.2); - - } - .am-selected-text { - color:#888; - } - } - .tpl-form-border-form input[type=number]:focus, .tpl-form-border-form input[type=search]:focus, .tpl-form-border-form input[type=text]:focus, .tpl-form-border-form input[type=password]:focus, .tpl-form-border-form input[type=datetime]:focus, .tpl-form-border-form input[type=datetime-local]:focus, .tpl-form-border-form input[type=date]:focus, .tpl-form-border-form input[type=month]:focus, .tpl-form-border-form input[type=time]:focus, .tpl-form-border-form input[type=week]:focus, .tpl-form-border-form input[type=email]:focus, .tpl-form-border-form input[type=url]:focus, .tpl-form-border-form input[type=tel]:focus, .tpl-form-border-form input[type=color]:focus, .tpl-form-border-form select:focus, .tpl-form-border-form textarea:focus, .am-form-field:focus{ - -webkit-box-shadow: none; - box-shadow: none; - } -.tpl-form-border-form input[type=number], .tpl-form-border-form input[type=search], .tpl-form-border-form input[type=text], .tpl-form-border-form input[type=password], .tpl-form-border-form input[type=datetime], .tpl-form-border-form input[type=datetime-local], .tpl-form-border-form input[type=date], .tpl-form-border-form input[type=month], .tpl-form-border-form input[type=time], .tpl-form-border-form input[type=week], .tpl-form-border-form input[type=email], .tpl-form-border-form input[type=url], .tpl-form-border-form input[type=tel], .tpl-form-border-form input[type=color], .tpl-form-border-form select, .tpl-form-border-form textarea, .am-form-field { - display: block; - width: 100%; - - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - -webkit-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - text-indent: .5em; - border: 1px solid rgba(255, 255, 255, 0.2); - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #fff; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} - -.tpl-form-border-form .am-checkbox, .tpl-form-border-form .am-checkbox-inline, .tpl-form-border-form .am-form-label, .tpl-form-border-form .am-radio, .tpl-form-border-form .am-radio-inline{ - margin-top: 0; - margin-bottom: 0; - -} - -.tpl-form-border-form .am-form-group:after { - clear: both; -} -.tpl-form-border-form .am-form-group:after, .tpl-form-border-form .am-form-group:before { -content: " "; - display: table; - -} -.tpl-form-border-form .am-form-label{ - padding-top: 5px; -font-size: 16px; -color: #fff; -font-weight: inherit; -text-align: right; -} -.tpl-form-border-form .am-form-group { - /*padding: 20px 0;*/ - -} -.tpl-form-border-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} - - - - - - - .tpl-form-line-form input[type=number]:focus, .tpl-form-line-form input[type=search]:focus, .tpl-form-line-form input[type=text]:focus, .tpl-form-line-form input[type=password]:focus, .tpl-form-line-form input[type=datetime]:focus, .tpl-form-line-form input[type=datetime-local]:focus, .tpl-form-line-form input[type=date]:focus, .tpl-form-line-form input[type=month]:focus, .tpl-form-line-form input[type=time]:focus, .tpl-form-line-form input[type=week]:focus, .tpl-form-line-form input[type=email]:focus, .tpl-form-line-form input[type=url]:focus, .tpl-form-line-form input[type=tel]:focus, .tpl-form-line-form input[type=color]:focus, .tpl-form-line-form select:focus, .tpl-form-line-form textarea:focus, .am-form-field:focus{ - -webkit-box-shadow: none; - box-shadow: none; - } -.tpl-form-line-form input[type=number], .tpl-form-line-form input[type=search], .tpl-form-line-form input[type=text], .tpl-form-line-form input[type=password], .tpl-form-line-form input[type=datetime], .tpl-form-line-form input[type=datetime-local], .tpl-form-line-form input[type=date], .tpl-form-line-form input[type=month], .tpl-form-line-form input[type=time], .tpl-form-line-form input[type=week], .tpl-form-line-form input[type=email], .tpl-form-line-form input[type=url], .tpl-form-line-form input[type=tel], .tpl-form-line-form input[type=color], .tpl-form-line-form select, .tpl-form-line-form textarea, .am-form-field { - display: block; - width: 100%; - - padding: 6px 12px; - font-size: 14px; - line-height: 1.42857; - color: #4d6b8a; - background-color: #fff; - background-image: none; - border: 1px solid #c2cad8; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - box-shadow: inset 0 1px 1px rgba(0,0,0,0.075); - -webkit-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - -o-transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - transition: border-color ease-in-out 0.15s,box-shadow ease-in-out 0.15s; - background: 0 0; - border: 0; - border-bottom: 1px solid rgba(255, 255, 255, 0.2); - -webkit-border-radius: 0; - -moz-border-radius: 0; - -ms-border-radius: 0; - -o-border-radius: 0; - border-radius: 0; - color: #fff; - box-shadow: none; - padding-left: 0; - padding-right: 0; - font-size: 14px; -} - -.tpl-form-line-form .am-checkbox, .tpl-form-line-form .am-checkbox-inline, .tpl-form-line-form .am-form-label, .tpl-form-line-form .am-radio, .tpl-form-line-form .am-radio-inline{ - margin-top: 0; - margin-bottom: 0; - -} - -.tpl-form-line-form .am-form-group:after { - clear: both; -} -.tpl-form-line-form .am-form-group:after, .tpl-form-line-form .am-form-group:before { -content: " "; - display: table; - -} -.tpl-form-line-form .am-form-label{ - padding-top: 5px; -font-size: 16px; -color: #fff; -font-weight: inherit; -text-align: right; -} - - - -.tpl-form-line-form .am-form-group { - /*padding: 20px 0;*/ - -} -.tpl-form-line-form .am-form-label .tpl-form-line-small-title { - color: #999; - font-size: 12px; -} - - background-color: #282d2f; - - .tpl-table-black-operation { - a { - border: 1px solid #7b878d; - color:#7b878d; - &:hover { - background: #7b878d; - color:#fff; - } - } - a.tpl-table-black-operation-del { - border: 1px solid #f35842; - color:#f35842; - &:hover { - background: #f35842; - color:#fff; - } - } -} - .am-table-bordered { - border: 1px solid #666d70; - } - .am-table-bordered>tbody>tr>td, .am-table-bordered>tbody>tr>th, .am-table-bordered>tfoot>tr>td, .am-table-bordered>tfoot>tr>th, .am-table-bordered>thead>tr>td, .am-table-bordered>thead>tr>th { - border: 1px solid #666d70; - } - - .am-table-bordered>thead+tbody>tr:first-child>td, .am-table-bordered>thead+tbody>tr:first-child>th { - border: 1px solid #666d70; - } - - .am-table-striped>tbody>tr:nth-child(odd)>td, .am-table-striped>tbody>tr:nth-child(odd)>th { - background-color: #5d6468; - } - .tpl-table-black { - color:#fff; - - thead>tr>th { - font-size: 14px; - padding: 6px; - border-bottom: 1px solid #666d70; - } - tbody>tr>td { - font-size: 14px; - padding: 7px 6px; - border-top: 1px solid #666d70; - } - tfoot>tr>th { - font-size: 14px; - padding: 6px 0; - } - } - .tpl-user-card { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; - } - .tpl-user-card-title { - font-size: 26px; - margin-top: 0; - font-weight: 300; - margin-top: 25px; - margin-bottom: 10px; - } - .achievement-subheading { - font-size: 12px; - margin-top: 0; - margin-bottom: 15px; - } - .achievement-image { - border-radius: 50%; - margin-bottom: 22px; - } - .achievement-description { - margin: 0; - font-size: 12px; - } - - - - .am-progress { - height: 12px; - margin-bottom: 14px; - background: rgba(0, 0, 0, 0.15); - } - .am-progress-title { - font-size: 14px; - margin-bottom: 8px; - } - .am-progress-title-more { - color: #a1a8ab; - } - .widget-fluctuation-tpl-btn { - margin-top: 6px; - display: block; - color: #fff; - font-size: 12px; - padding: 5px 10px; - outline: none; - background-color: rgba(255, 255, 255, 0); - border: 1px solid #fff; - &:hover { - background: #fff; - color:#4b5357; - } - - } -.widget-fluctuation-description-text{ -color: #c5cacd; - } - - .text-success { - color: #08ed72; -} -.widget-fluctuation-period-text { - color:#fff; - } - - .widget-head { - border-bottom: 1px solid #3f4649; -} - .widget-function { - a { - color:#7b878d; - &:hover { - color:#fff; - } - } - - } - .widget { - border: 1px solid #33393c; - border-top: 2px solid #313639; - background: #4b5357; - color: #ffffff; - } - .widget-primary { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; - padding: 12px 17px; -} -.widget-statistic-body { - -} -.widget-statistic-icon { - position: absolute; - z-index: 30; - right: 30px; - top: 0px; - font-size: 70px; - color: #1b9eca; -} -.widget-statistic-description { - position: relative; - z-index: 35; - display: block; - font-size: 14px; - line-height: 14px; - padding-top: 8px; - color: #9cdcf2; -} -.widget-statistic-value { - position: relative; - z-index: 35; - font-weight: 300; - display: block; - color: #fff; - font-size: 46px; - line-height: 46px; - margin-bottom: 8px; -} -.widget-statistic-header { - color: #9cdcf2; -} - -.widget-purple { - padding: 12px 17px; - border: 1px solid #5e4578; - border-top: 2px solid #5c4375; - background: #785799; - color: #ffffff; - .widget-statistic-icon { - color: #8a6aaa; - } - .widget-statistic-header { - color: #ded5e7; - } - .widget-statistic-description { - color: #ded5e7; - } -} - .page-header-description { - color: #e6e6e6; - } - .page-header-heading { - color: #666; - } - .container-fluid { - background: #424b4f; - } - .page-header-heading { - color: #fff; - } - .sidebar-nav-heading { - color:#fff; - } - .tpl-sidebar-user-panel { - background: #1f2224; - border-bottom: 1px solid #1f2224; -} - .tpl-content-wrapper { - background: #3a4144; - } - .tpl-header-fluid { - background: #2f3638; - -} - - .sidebar-nav-link { - a.active { - background: #232829; - } - a:hover { - - background: #232829; - } - } - -.tpl-header-switch-button { - background: #2f3638; - border-right: 1px solid #282d2f; - &:hover { - background: #282d2f; - color: #fff; - } -} - .tpl-header-navbar { - a { - color:#cfcfcf; - - &:hover { - color: #fff; - } - } - } - .left-sidebar { - padding-top: 56px; - background: #282d2f; - } - - .widget-color-green { - border: 1px solid #11627d; - border-top: 2px solid #105f79; - background: #1786aa; - color: #ffffff; - .widget-head { - border-bottom: 1px solid #147494; - } - .widget-fluctuation-description-text { - color:#bbe7f6; - } - .widget-function { - a { - color:#42bde5; - &:hover { - color: #fff; - } - } - } - } -} - - - -@media screen and (max-width: 1024px) { - .tpl-index-settings-button { - display: none; - } - - .theme-black .left-sidebar { - padding-top: 111px; - } - .left-sidebar { - padding-top: 111px; - } - .tpl-content-wrapper { - margin-left: 0 - } - .tpl-header-logo { - float:none; - width: 100%; - } - .tpl-header-navbar-welcome { - display: none; - } - - .tpl-sidebar-user-panel { - border-top: 1px solid #eee; - } - .tpl-header-fluid { - border-top: none; - margin-left: 0; - } - - .theme-white .tpl-header-fluid { - border-top: none; - } - .theme-black .tpl-sidebar-user-panel { - border-top: 1px solid #1f2224; - } -} - -@media screen and (min-width: 641px) { - [class*=am-u-] { - padding-left: 10px; - padding-right: 10px; -} -} -@media screen and (max-width: 641px) { - - .theme-white , .theme-black { - .tpl-error-title { - font-size: 130px; - line-height: 140px; - - } - } - .theme-white { - - .tpl-login-title { - font-size: 20px; - } - .tpl-login-content{ - width: 86%; - padding: 22px 30px 25px; - } - } - - - - .tpl-header-search { - display: none; - } - ul.tpl-dropdown-content { - position: fixed; - width: 100%; - left: 0; - top: 112px; - right: 0; - } -} \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/css/fullcalendar.min.css b/Day61-65/code/project_of_tornado/assets/css/fullcalendar.min.css deleted file mode 100644 index f9fa1c1..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/fullcalendar.min.css +++ /dev/null @@ -1,5 +0,0 @@ -/*! - * FullCalendar v0.0.0 Stylesheet - * Docs & License: http://fullcalendar.io/ - * (c) 2016 Adam Shaw - */.fc-icon,body .fc{font-size:1em}.fc-button-group,.fc-icon{display:inline-block}.fc-bg,.fc-row .fc-bgevent-skeleton,.fc-row .fc-highlight-skeleton{bottom:0}.fc-icon,.fc-unselectable{-khtml-user-select:none;-webkit-touch-callout:none}.fc{direction:ltr;text-align:left}.fc-rtl{text-align:right}.fc th,.fc-basic-view td.fc-week-number,.fc-icon,.fc-toolbar{text-align:center}.fc-unthemed .fc-content,.fc-unthemed .fc-divider,.fc-unthemed .fc-list-heading td,.fc-unthemed .fc-list-view,.fc-unthemed .fc-popover,.fc-unthemed .fc-row,.fc-unthemed tbody,.fc-unthemed td,.fc-unthemed th,.fc-unthemed thead{border-color:#ddd}.fc-unthemed .fc-popover{background-color:#fff}.fc-unthemed .fc-divider,.fc-unthemed .fc-list-heading td,.fc-unthemed .fc-popover .fc-header{background:#eee}.fc-unthemed .fc-popover .fc-header .fc-close{color:#666}.fc-unthemed .fc-today{background:#fcf8e3}.fc-highlight{background:#bce8f1;opacity:.3}.fc-bgevent{background:#8fdf82;opacity:.3}.fc-nonbusiness{background:#d7d7d7}.fc-icon{height:1em;line-height:1em;overflow:hidden;font-family:"Courier New",Courier,monospace;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.fc-icon:after{position:relative}.fc-icon-left-single-arrow:after{content:"\02039";font-weight:700;font-size:200%;top:-7%}.fc-icon-right-single-arrow:after{content:"\0203A";font-weight:700;font-size:200%;top:-7%}.fc-icon-left-double-arrow:after{content:"\000AB";font-size:160%;top:-7%}.fc-icon-right-double-arrow:after{content:"\000BB";font-size:160%;top:-7%}.fc-icon-left-triangle:after{content:"\25C4";font-size:125%;top:3%}.fc-icon-right-triangle:after{content:"\25BA";font-size:125%;top:3%}.fc-icon-down-triangle:after{content:"\25BC";font-size:125%;top:2%}.fc-icon-x:after{content:"\000D7";font-size:200%;top:6%}.fc button{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0;height:2.1em;padding:0 .6em;font-size:1em;white-space:nowrap;cursor:pointer}.fc button::-moz-focus-inner{margin:0;padding:0}.fc-state-default{border:1px solid;background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.fc-state-default.fc-corner-left{border-top-left-radius:4px;border-bottom-left-radius:4px}.fc-state-default.fc-corner-right{border-top-right-radius:4px;border-bottom-right-radius:4px}.fc button .fc-icon{position:relative;top:-.05em;margin:0 .2em;vertical-align:middle}.fc-state-active,.fc-state-disabled,.fc-state-down,.fc-state-hover{color:#333;background-color:#e6e6e6}.fc-state-hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.fc-state-active,.fc-state-down{background-color:#ccc;background-image:none;box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.fc-state-disabled{cursor:default;background-image:none;opacity:.65;box-shadow:none}.fc-event.fc-draggable,.fc-event[href],.fc-popover .fc-header .fc-close,a[data-goto]{cursor:pointer}.fc .fc-button-group>*{float:left;margin:0 0 0 -1px}.fc .fc-button-group>:first-child{margin-left:0}.fc-popover{position:absolute;box-shadow:0 2px 6px rgba(0,0,0,.15)}.fc-popover .fc-header{padding:2px 4px}.fc-popover .fc-header .fc-title{margin:0 2px}.fc-ltr .fc-popover .fc-header .fc-title,.fc-rtl .fc-popover .fc-header .fc-close{float:left}.fc-ltr .fc-popover .fc-header .fc-close,.fc-rtl .fc-popover .fc-header .fc-title{float:right}.fc-unthemed .fc-popover{border-width:1px;border-style:solid}.fc-unthemed .fc-popover .fc-header .fc-close{font-size:.9em;margin-top:2px}.fc-popover>.ui-widget-header+.ui-widget-content{border-top:0}.fc-divider{border-style:solid;border-width:1px}hr.fc-divider{height:0;margin:0;padding:0 0 2px;border-width:1px 0}.fc-bg table,.fc-row .fc-bgevent-skeleton table,.fc-row .fc-highlight-skeleton table{height:100%}.fc-clear{clear:both}.fc-bg,.fc-bgevent-skeleton,.fc-helper-skeleton,.fc-highlight-skeleton{position:absolute;top:0;left:0;right:0}.fc table{width:100%;box-sizing:border-box;table-layout:fixed;border-collapse:collapse;border-spacing:0;font-size:1em}.fc td,.fc th{border-style:solid;border-width:1px;padding:0;vertical-align:top}.fc td.fc-today{border-style:double}a[data-goto]:hover{text-decoration:underline}.fc .fc-row{border-style:solid;border-width:0}.fc-row table{border-left:0 hidden transparent;border-right:0 hidden transparent;border-bottom:0 hidden transparent}.fc-row:first-child table{border-top:0 hidden transparent}.fc-row{position:relative}.fc-row .fc-bg{z-index:1}.fc-row .fc-bgevent-skeleton td,.fc-row .fc-highlight-skeleton td{border-color:transparent}.fc-row .fc-bgevent-skeleton{z-index:2}.fc-row .fc-highlight-skeleton{z-index:3}.fc-row .fc-content-skeleton{position:relative;z-index:4;padding-bottom:2px}.fc-row .fc-helper-skeleton{z-index:5}.fc-row .fc-content-skeleton td,.fc-row .fc-helper-skeleton td{background:0 0;border-color:transparent;border-bottom:0}.fc-row .fc-content-skeleton tbody td,.fc-row .fc-helper-skeleton tbody td{border-top:0}.fc-scroller{-webkit-overflow-scrolling:touch}.fc-row.fc-rigid,.fc-time-grid-event{overflow:hidden}.fc-scroller>.fc-day-grid,.fc-scroller>.fc-time-grid{position:relative;width:100%}.fc-event{position:relative;display:block;font-size:.85em;line-height:1.3;border-radius:3px;border:1px solid #3a87ad;font-weight:400}.fc-event,.fc-event-dot{background-color:#3a87ad}.fc-event,.fc-event:hover,.ui-widget .fc-event{color:#fff;text-decoration:none}.fc-not-allowed,.fc-not-allowed .fc-event{cursor:not-allowed}.fc-event .fc-bg{z-index:1;background:#fff;opacity:.25}.fc-event .fc-content{position:relative;z-index:2}.fc-event .fc-resizer{position:absolute;z-index:4;display:none}.fc-event.fc-allow-mouse-resize .fc-resizer,.fc-event.fc-selected .fc-resizer{display:block}.fc-event.fc-selected .fc-resizer:before{content:"";position:absolute;z-index:9999;top:50%;left:50%;width:40px;height:40px;margin-left:-20px;margin-top:-20px}.fc-event.fc-selected{z-index:9999!important;box-shadow:0 2px 5px rgba(0,0,0,.2)}.fc-event.fc-selected.fc-dragging{box-shadow:0 2px 7px rgba(0,0,0,.3)}.fc-h-event.fc-selected:before{content:"";position:absolute;z-index:3;top:-10px;bottom:-10px;left:0;right:0}.fc-ltr .fc-h-event.fc-not-start,.fc-rtl .fc-h-event.fc-not-end{margin-left:0;border-left-width:0;padding-left:1px;border-top-left-radius:0;border-bottom-left-radius:0}.fc-ltr .fc-h-event.fc-not-end,.fc-rtl .fc-h-event.fc-not-start{margin-right:0;border-right-width:0;padding-right:1px;border-top-right-radius:0;border-bottom-right-radius:0}.fc-ltr .fc-h-event .fc-start-resizer,.fc-rtl .fc-h-event .fc-end-resizer{cursor:w-resize;left:-1px}.fc-ltr .fc-h-event .fc-end-resizer,.fc-rtl .fc-h-event .fc-start-resizer{cursor:e-resize;right:-1px}.fc-h-event.fc-allow-mouse-resize .fc-resizer{width:7px;top:-1px;bottom:-1px}.fc-h-event.fc-selected .fc-resizer{border-radius:4px;border-width:1px;width:6px;height:6px;border-style:solid;border-color:inherit;background:#fff;top:50%;margin-top:-4px}.fc-ltr .fc-h-event.fc-selected .fc-start-resizer,.fc-rtl .fc-h-event.fc-selected .fc-end-resizer{margin-left:-4px}.fc-ltr .fc-h-event.fc-selected .fc-end-resizer,.fc-rtl .fc-h-event.fc-selected .fc-start-resizer{margin-right:-4px}.fc-day-grid-event{margin:1px 2px 0;padding:0 1px}tr:first-child>td>.fc-day-grid-event{margin-top:2px}.fc-day-grid-event.fc-selected:after{content:"";position:absolute;z-index:1;top:-1px;right:-1px;bottom:-1px;left:-1px;background:#000;opacity:.25}.fc-day-grid-event .fc-content{white-space:nowrap;overflow:hidden}.fc-day-grid-event .fc-time{font-weight:700}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer{margin-left:-2px}.fc-ltr .fc-day-grid-event.fc-allow-mouse-resize .fc-end-resizer,.fc-rtl .fc-day-grid-event.fc-allow-mouse-resize .fc-start-resizer{margin-right:-2px}a.fc-more{margin:1px 3px;font-size:.85em;cursor:pointer;text-decoration:none}a.fc-more:hover{text-decoration:underline}.fc-limited{display:none}.fc-day-grid .fc-row{z-index:1}.fc-more-popover{z-index:2;width:220px}.fc-more-popover .fc-event-container{padding:10px}.fc-now-indicator{position:absolute;border:0 solid red}.fc-unselectable{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.fc-toolbar{margin-bottom:1em}.fc-toolbar .fc-left{float:left}.fc-toolbar .fc-right{float:right}.fc-toolbar .fc-center{display:inline-block}.fc .fc-toolbar>*>*{float:left;margin-left:.75em}.fc .fc-toolbar>*>:first-child{margin-left:0}.fc-toolbar h2{margin:0}.fc-toolbar button{position:relative}.fc-toolbar .fc-state-hover,.fc-toolbar .ui-state-hover{z-index:2}.fc-toolbar .fc-state-down{z-index:3}.fc-toolbar .fc-state-active,.fc-toolbar .ui-state-active{z-index:4}.fc-toolbar button:focus{z-index:5}.fc-view-container *,.fc-view-container :after,.fc-view-container :before{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.fc-view,.fc-view>table{position:relative;z-index:1}.fc-basicDay-view .fc-content-skeleton,.fc-basicWeek-view .fc-content-skeleton{padding-bottom:1em}.fc-basic-view .fc-body .fc-row{min-height:4em}.fc-row.fc-rigid .fc-content-skeleton{position:absolute;top:0;left:0;right:0}.fc-day-top.fc-other-month{opacity:.3}.fc-basic-view .fc-day-number,.fc-basic-view .fc-week-number{padding:2px}.fc-basic-view th.fc-day-number,.fc-basic-view th.fc-week-number{padding:0 2px}.fc-ltr .fc-basic-view .fc-day-top .fc-day-number{float:right}.fc-rtl .fc-basic-view .fc-day-top .fc-day-number{float:left}.fc-ltr .fc-basic-view .fc-day-top .fc-week-number{float:left;border-radius:0 0 3px}.fc-rtl .fc-basic-view .fc-day-top .fc-week-number{float:right;border-radius:0 0 0 3px}.fc-basic-view .fc-day-top .fc-week-number{min-width:1.5em;text-align:center;background-color:#f2f2f2;color:grey}.fc-basic-view td.fc-week-number>*{display:inline-block;min-width:1.25em}.fc-agenda-view .fc-day-grid{position:relative;z-index:2}.fc-agenda-view .fc-day-grid .fc-row{min-height:3em}.fc-agenda-view .fc-day-grid .fc-row .fc-content-skeleton{padding-bottom:1em}.fc .fc-axis{vertical-align:middle;padding:0 4px;white-space:nowrap}.fc-ltr .fc-axis{text-align:right}.fc-rtl .fc-axis{text-align:left}.ui-widget td.fc-axis{font-weight:400}.fc-time-grid,.fc-time-grid-container{position:relative;z-index:1}.fc-time-grid{min-height:100%}.fc-time-grid table{border:0 hidden transparent}.fc-time-grid>.fc-bg{z-index:1}.fc-time-grid .fc-slats,.fc-time-grid>hr{position:relative;z-index:2}.fc-time-grid .fc-content-col{position:relative}.fc-time-grid .fc-content-skeleton{position:absolute;z-index:3;top:0;left:0;right:0}.fc-time-grid .fc-business-container{position:relative;z-index:1}.fc-time-grid .fc-bgevent-container{position:relative;z-index:2}.fc-time-grid .fc-highlight-container{z-index:3;position:relative}.fc-time-grid .fc-event-container{position:relative;z-index:4}.fc-time-grid .fc-now-indicator-line{z-index:5}.fc-time-grid .fc-helper-container{position:relative;z-index:6}.fc-time-grid .fc-slats td{height:1.5em;border-bottom:0}.fc-time-grid .fc-slats .fc-minor td{border-top-style:dotted}.fc-time-grid .fc-slats .ui-widget-content{background:0 0}.fc-time-grid .fc-highlight{position:absolute;left:0;right:0}.fc-ltr .fc-time-grid .fc-event-container{margin:0 2.5% 0 2px}.fc-rtl .fc-time-grid .fc-event-container{margin:0 2px 0 2.5%}.fc-time-grid .fc-bgevent,.fc-time-grid .fc-event{position:absolute;z-index:1}.fc-time-grid .fc-bgevent{left:0;right:0}.fc-v-event.fc-not-start{border-top-width:0;padding-top:1px;border-top-left-radius:0;border-top-right-radius:0}.fc-v-event.fc-not-end{border-bottom-width:0;padding-bottom:1px;border-bottom-left-radius:0;border-bottom-right-radius:0}.fc-time-grid-event.fc-selected{overflow:visible}.fc-time-grid-event.fc-selected .fc-bg{display:none}.fc-time-grid-event .fc-content{overflow:hidden}.fc-time-grid-event .fc-time,.fc-time-grid-event .fc-title{padding:0 1px}.fc-time-grid-event .fc-time{font-size:.85em;white-space:nowrap}.fc-time-grid-event.fc-short .fc-content{white-space:nowrap}.fc-time-grid-event.fc-short .fc-time,.fc-time-grid-event.fc-short .fc-title{display:inline-block;vertical-align:top}.fc-time-grid-event.fc-short .fc-time span{display:none}.fc-time-grid-event.fc-short .fc-time:before{content:attr(data-start)}.fc-time-grid-event.fc-short .fc-time:after{content:"\000A0-\000A0"}.fc-time-grid-event.fc-short .fc-title{font-size:.85em;padding:0}.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer{left:0;right:0;bottom:0;height:8px;overflow:hidden;line-height:8px;font-size:11px;font-family:monospace;text-align:center;cursor:s-resize}.fc-time-grid-event.fc-allow-mouse-resize .fc-resizer:after{content:"="}.fc-time-grid-event.fc-selected .fc-resizer{border-radius:5px;border-width:1px;width:8px;height:8px;border-style:solid;border-color:inherit;background:#fff;left:50%;margin-left:-5px;bottom:-5px}.fc-time-grid .fc-now-indicator-line{border-top-width:1px;left:0;right:0}.fc-time-grid .fc-now-indicator-arrow{margin-top:-5px}.fc-ltr .fc-time-grid .fc-now-indicator-arrow{left:0;border-width:5px 0 5px 6px;border-top-color:transparent;border-bottom-color:transparent}.fc-rtl .fc-time-grid .fc-now-indicator-arrow{right:0;border-width:5px 6px 5px 0;border-top-color:transparent;border-bottom-color:transparent}.fc-event-dot{display:inline-block;width:10px;height:10px;border-radius:5px}.fc-rtl .fc-list-view{direction:rtl}.fc-list-view{border-width:1px;border-style:solid}.fc .fc-list-table{table-layout:auto}.fc-list-table td{border-width:1px 0 0;padding:8px 14px}.fc-list-table tr:first-child td{border-top-width:0}.fc-list-heading{border-bottom-width:1px}.fc-list-heading td{font-weight:700}.fc-ltr .fc-list-heading-main{float:left}.fc-ltr .fc-list-heading-alt,.fc-rtl .fc-list-heading-main{float:right}.fc-rtl .fc-list-heading-alt{float:left}.fc-list-item.fc-has-url{cursor:pointer}.fc-list-item:hover td{background-color:#f5f5f5}.fc-list-item-marker,.fc-list-item-time{white-space:nowrap;width:1px}.fc-ltr .fc-list-item-marker{padding-right:0}.fc-rtl .fc-list-item-marker{padding-left:0}.fc-list-item-title a{text-decoration:none;color:inherit}.fc-list-item-title a[href]:hover{text-decoration:underline}.fc-list-empty-wrap2{position:absolute;top:0;left:0;right:0;bottom:0}.fc-list-empty-wrap1{width:100%;height:100%;display:table}.fc-list-empty{display:table-cell;vertical-align:middle;text-align:center}.fc-unthemed .fc-list-empty{background-color:#eee} \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/css/fullcalendar.print.css b/Day61-65/code/project_of_tornado/assets/css/fullcalendar.print.css deleted file mode 100644 index ad1a023..0000000 --- a/Day61-65/code/project_of_tornado/assets/css/fullcalendar.print.css +++ /dev/null @@ -1,208 +0,0 @@ -/*! - * FullCalendar v0.0.0 Print Stylesheet - * Docs & License: http://fullcalendar.io/ - * (c) 2016 Adam Shaw - */ - -/* - * Include this stylesheet on your page to get a more printer-friendly calendar. - * When including this stylesheet, use the media='print' attribute of the tag. - * Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css. - */ - -.fc { - max-width: 100% !important; -} - - -/* Global Event Restyling ---------------------------------------------------------------------------------------------------*/ - -.fc-event { - background: #fff !important; - color: #000 !important; - page-break-inside: avoid; -} - -.fc-event .fc-resizer { - display: none; -} - - -/* Table & Day-Row Restyling ---------------------------------------------------------------------------------------------------*/ - -.fc th, -.fc td, -.fc hr, -.fc thead, -.fc tbody, -.fc-row { - border-color: #ccc !important; - background: #fff !important; -} - -/* kill the overlaid, absolutely-positioned components */ -/* common... */ -.fc-bg, -.fc-bgevent-skeleton, -.fc-highlight-skeleton, -.fc-helper-skeleton, -/* for timegrid. within cells within table skeletons... */ -.fc-bgevent-container, -.fc-business-container, -.fc-highlight-container, -.fc-helper-container { - display: none; -} - -/* don't force a min-height on rows (for DayGrid) */ -.fc tbody .fc-row { - height: auto !important; /* undo height that JS set in distributeHeight */ - min-height: 0 !important; /* undo the min-height from each view's specific stylesheet */ -} - -.fc tbody .fc-row .fc-content-skeleton { - position: static; /* undo .fc-rigid */ - padding-bottom: 0 !important; /* use a more border-friendly method for this... */ -} - -.fc tbody .fc-row .fc-content-skeleton tbody tr:last-child td { /* only works in newer browsers */ - padding-bottom: 1em; /* ...gives space within the skeleton. also ensures min height in a way */ -} - -.fc tbody .fc-row .fc-content-skeleton table { - /* provides a min-height for the row, but only effective for IE, which exaggerates this value, - making it look more like 3em. for other browers, it will already be this tall */ - height: 1em; -} - - -/* Undo month-view event limiting. Display all events and hide the "more" links ---------------------------------------------------------------------------------------------------*/ - -.fc-more-cell, -.fc-more { - display: none !important; -} - -.fc tr.fc-limited { - display: table-row !important; -} - -.fc td.fc-limited { - display: table-cell !important; -} - -.fc-popover { - display: none; /* never display the "more.." popover in print mode */ -} - - -/* TimeGrid Restyling ---------------------------------------------------------------------------------------------------*/ - -/* undo the min-height 100% trick used to fill the container's height */ -.fc-time-grid { - min-height: 0 !important; -} - -/* don't display the side axis at all ("all-day" and time cells) */ -.fc-agenda-view .fc-axis { - display: none; -} - -/* don't display the horizontal lines */ -.fc-slats, -.fc-time-grid hr { /* this hr is used when height is underused and needs to be filled */ - display: none !important; /* important overrides inline declaration */ -} - -/* let the container that holds the events be naturally positioned and create real height */ -.fc-time-grid .fc-content-skeleton { - position: static; -} - -/* in case there are no events, we still want some height */ -.fc-time-grid .fc-content-skeleton table { - height: 4em; -} - -/* kill the horizontal spacing made by the event container. event margins will be done below */ -.fc-time-grid .fc-event-container { - margin: 0 !important; -} - - -/* TimeGrid *Event* Restyling ---------------------------------------------------------------------------------------------------*/ - -/* naturally position events, vertically stacking them */ -.fc-time-grid .fc-event { - position: static !important; - margin: 3px 2px !important; -} - -/* for events that continue to a future day, give the bottom border back */ -.fc-time-grid .fc-event.fc-not-end { - border-bottom-width: 1px !important; -} - -/* indicate the event continues via "..." text */ -.fc-time-grid .fc-event.fc-not-end:after { - content: "..."; -} - -/* for events that are continuations from previous days, give the top border back */ -.fc-time-grid .fc-event.fc-not-start { - border-top-width: 1px !important; -} - -/* indicate the event is a continuation via "..." text */ -.fc-time-grid .fc-event.fc-not-start:before { - content: "..."; -} - -/* time */ - -/* undo a previous declaration and let the time text span to a second line */ -.fc-time-grid .fc-event .fc-time { - white-space: normal !important; -} - -/* hide the the time that is normally displayed... */ -.fc-time-grid .fc-event .fc-time span { - display: none; -} - -/* ...replace it with a more verbose version (includes AM/PM) stored in an html attribute */ -.fc-time-grid .fc-event .fc-time:after { - content: attr(data-full); -} - - -/* Vertical Scroller & Containers ---------------------------------------------------------------------------------------------------*/ - -/* kill the scrollbars and allow natural height */ -.fc-scroller, -.fc-day-grid-container, /* these divs might be assigned height, which we need to cleared */ -.fc-time-grid-container { /* */ - overflow: visible !important; - height: auto !important; -} - -/* kill the horizontal border/padding used to compensate for scrollbars */ -.fc-row { - border: 0 !important; - margin: 0 !important; -} - - -/* Button Controls ---------------------------------------------------------------------------------------------------*/ - -.fc-button-group, -.fc button { - display: none; /* don't display any button-related controls */ -} diff --git a/Day61-65/code/project_of_tornado/assets/fonts/FontAwesome.otf b/Day61-65/code/project_of_tornado/assets/fonts/FontAwesome.otf deleted file mode 100644 index d4de13e..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/fonts/FontAwesome.otf and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.eot b/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.eot deleted file mode 100644 index c7b00d2..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.eot and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.ttf b/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.ttf deleted file mode 100644 index f221e50..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.ttf and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff b/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff deleted file mode 100644 index 6e7483c..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff2 b/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff2 deleted file mode 100644 index 7eb74fd..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/fonts/fontawesome-webfont.woff2 and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/html/404.html b/Day61-65/code/project_of_tornado/assets/html/404.html deleted file mode 100644 index 48f614c..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/404.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - - - -
    - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/calendar.html b/Day61-65/code/project_of_tornado/assets/html/calendar.html deleted file mode 100644 index 8c4cb41..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/calendar.html +++ /dev/null @@ -1,453 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - - - -
    - - - - -
    -
    -
    - × -
    -
    - -
    -
    - -
    - -
    -
    - - - - - - - -
    - -
    -
    -
    - - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/chart.html b/Day61-65/code/project_of_tornado/assets/html/chart.html deleted file mode 100644 index f247f77..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/chart.html +++ /dev/null @@ -1,341 +0,0 @@ - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - -
    - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/form.html b/Day61-65/code/project_of_tornado/assets/html/form.html deleted file mode 100644 index 453811e..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/form.html +++ /dev/null @@ -1,619 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - - -
    - -
    - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - - - - -
    - -
    -
    -
    -
    表单 Amaze UI
    -

    Amaze UI 有许多不同的表格可用。

    -
    -
    - -
    -
    - -
    - -
    - - -
    - -
    -
    -
    -
    线条表单
    -
    - -
    -
    -
    - -
    -
    - -
    - - 请填写标题文字10-20字左右。 -
    -
    - -
    - -
    - - 发布时间为必填 -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    -
    -
    - -
    - - -
    - -
    -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    边框表单
    -
    - -
    -
    -
    - -
    -
    - -
    - - 请填写标题文字10-20字左右。 -
    -
    - -
    - -
    - - 发布时间为必填 -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    -
    -
    - -
    - - -
    - -
    -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    换行边框
    -
    - -
    -
    -
    - -
    -
    - -
    - - 请填写标题文字10-20字左右。 -
    -
    - -
    - -
    - - 发布时间为必填 -
    -
    - -
    - -
    - - -
    -
    - -
    - -
    - -
    -
    - -
    - -
    -
    -
    - -
    - - -
    - -
    -
    - -
    - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    - - -
    -
    -
    - - - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/login.html b/Day61-65/code/project_of_tornado/assets/html/login.html deleted file mode 100644 index eca4073..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/login.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - -
    - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/sign-up.html b/Day61-65/code/project_of_tornado/assets/html/sign-up.html deleted file mode 100644 index d10b4a6..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/sign-up.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - -
    - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/table-list-img.html b/Day61-65/code/project_of_tornado/assets/html/table-list-img.html deleted file mode 100644 index 706c280..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/table-list-img.html +++ /dev/null @@ -1,469 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - -
    - -
    - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - - - -
    -
    -
    -
    -
    -
    -
    文章列表
    - - -
    -
    - -
    -
    -
    -
    - - - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - - - -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章缩略图文章标题作者时间操作
    - - Amaze UI 模式窗口张鹏飞2016-09-26 - -
    - - 有适配微信小程序的计划吗天纵之人2016-09-26 - -
    - - 请问有没有amazeui 分享插件王宽师2016-09-26 - -
    - - 关于input输入框的问题着迷2016-09-26 - -
    - - 有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    - - 我建议WEB版本文件引入问题罢了2016-09-26 - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/table-list.html b/Day61-65/code/project_of_tornado/assets/html/table-list.html deleted file mode 100644 index 9d2c589..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/table-list.html +++ /dev/null @@ -1,461 +0,0 @@ - - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - - - -
    - -
    - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - - - -
    -
    -
    -
    -
    -
    -
    文章列表
    - - -
    -
    - -
    -
    -
    -
    - - - - -
    -
    -
    -
    -
    -
    - -
    -
    -
    -
    - - - - -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章标题作者时间操作
    Amaze UI 模式窗口张鹏飞2016-09-26 - -
    有适配微信小程序的计划吗天纵之人2016-09-26 - -
    请问有没有amazeui 分享插件王宽师2016-09-26 - -
    关于input输入框的问题着迷2016-09-26 - -
    有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    我建议WEB版本文件引入问题罢了2016-09-26 - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/html/tables.html b/Day61-65/code/project_of_tornado/assets/html/tables.html deleted file mode 100644 index cf282e2..0000000 --- a/Day61-65/code/project_of_tornado/assets/html/tables.html +++ /dev/null @@ -1,834 +0,0 @@ - - - - - - Amaze UI Admin index Examples - - - - - - - - - - - - - - - - -
    - -
    - - - - - -
    - -
    -
    -
    -
    -
    - 选择主题 -
    -
    - - -
    -
    -
    - - - -
    -
    -
    -
    -
    表格 - Amaze UI -
    -

    Amaze UI 有许多不同的表格可用。

    -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    滚动条表格
    -
    - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - -
    工号姓名职位月薪自我介绍
    {{ emp.no }}{{ emp.name }}{{ emp.job }}{{ emp.sal }}{{ emp.intro }} - -
    -
    - -
    -
    -
    - -
    -
    -
    -
    自适应表格
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章标题作者时间操作
    Amaze UI 模式窗口张鹏飞2016-09-26 - -
    有适配微信小程序的计划吗天纵之人2016-09-26 - -
    请问有没有amazeui 分享插件王宽师2016-09-26 - -
    关于input输入框的问题着迷2016-09-26 - -
    有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    我建议WEB版本文件引入问题罢了2016-09-26 - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    基本边框
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章标题作者时间操作
    Amaze UI 模式窗口张鹏飞2016-09-26 - -
    有适配微信小程序的计划吗天纵之人2016-09-26 - -
    请问有没有amazeui 分享插件王宽师2016-09-26 - -
    关于input输入框的问题着迷2016-09-26 - -
    有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    我建议WEB版本文件引入问题罢了2016-09-26 - -
    - -
    -
    -
    - -
    -
    -
    -
    圆角斑马线边框
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章标题作者时间操作
    Amaze UI 模式窗口张鹏飞2016-09-26 - -
    有适配微信小程序的计划吗天纵之人2016-09-26 - -
    请问有没有amazeui 分享插件王宽师2016-09-26 - -
    关于input输入框的问题着迷2016-09-26 - -
    有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    我建议WEB版本文件引入问题罢了2016-09-26 - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    -
    斑马线
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    文章标题作者时间操作
    Amaze UI 模式窗口张鹏飞2016-09-26 - -
    有适配微信小程序的计划吗天纵之人2016-09-26 - -
    请问有没有amazeui 分享插件王宽师2016-09-26 - -
    关于input输入框的问题着迷2016-09-26 - -
    有没有发现官网上的下载包不好用醉里挑灯看键2016-09-26 - -
    我建议WEB版本文件引入问题罢了2016-09-26 - -
    - -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/i/app-icon72x72@2x.png b/Day61-65/code/project_of_tornado/assets/i/app-icon72x72@2x.png deleted file mode 100644 index 5b8968c..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/app-icon72x72@2x.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/admin-chrome.png b/Day61-65/code/project_of_tornado/assets/i/examples/admin-chrome.png deleted file mode 100644 index a607757..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/admin-chrome.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/admin-firefox.png b/Day61-65/code/project_of_tornado/assets/i/examples/admin-firefox.png deleted file mode 100644 index 157477d..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/admin-firefox.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/admin-ie.png b/Day61-65/code/project_of_tornado/assets/i/examples/admin-ie.png deleted file mode 100644 index dc3374c..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/admin-ie.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/admin-opera.png b/Day61-65/code/project_of_tornado/assets/i/examples/admin-opera.png deleted file mode 100644 index f9ff739..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/admin-opera.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/admin-safari.png b/Day61-65/code/project_of_tornado/assets/i/examples/admin-safari.png deleted file mode 100644 index 5354ed8..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/admin-safari.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/adminPage.png b/Day61-65/code/project_of_tornado/assets/i/examples/adminPage.png deleted file mode 100644 index 1b95832..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/adminPage.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/blogPage.png b/Day61-65/code/project_of_tornado/assets/i/examples/blogPage.png deleted file mode 100644 index 96a09bb..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/blogPage.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/landing.png b/Day61-65/code/project_of_tornado/assets/i/examples/landing.png deleted file mode 100644 index bb18e9a..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/landing.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/landingPage.png b/Day61-65/code/project_of_tornado/assets/i/examples/landingPage.png deleted file mode 100644 index 91ca883..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/landingPage.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/loginPage.png b/Day61-65/code/project_of_tornado/assets/i/examples/loginPage.png deleted file mode 100644 index f695210..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/loginPage.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/examples/sidebarPage.png b/Day61-65/code/project_of_tornado/assets/i/examples/sidebarPage.png deleted file mode 100644 index 4dbdb39..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/examples/sidebarPage.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/favicon.png b/Day61-65/code/project_of_tornado/assets/i/favicon.png deleted file mode 100644 index 0958158..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/favicon.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/i/startup-640x1096.png b/Day61-65/code/project_of_tornado/assets/i/startup-640x1096.png deleted file mode 100644 index 953a44c..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/i/startup-640x1096.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/a5.png b/Day61-65/code/project_of_tornado/assets/img/a5.png deleted file mode 100644 index 25afda8..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/a5.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/k.jpg b/Day61-65/code/project_of_tornado/assets/img/k.jpg deleted file mode 100644 index 6546e88..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/k.jpg and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/logo.png b/Day61-65/code/project_of_tornado/assets/img/logo.png deleted file mode 100644 index 5c0d189..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/logo.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/logoa.png b/Day61-65/code/project_of_tornado/assets/img/logoa.png deleted file mode 100644 index c838876..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/logoa.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/logob.png b/Day61-65/code/project_of_tornado/assets/img/logob.png deleted file mode 100644 index 2d6d5a0..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/logob.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user01.png b/Day61-65/code/project_of_tornado/assets/img/user01.png deleted file mode 100644 index 1a21a35..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user01.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user02.png b/Day61-65/code/project_of_tornado/assets/img/user02.png deleted file mode 100644 index b023f02..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user02.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user03.png b/Day61-65/code/project_of_tornado/assets/img/user03.png deleted file mode 100644 index 0a6ceae..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user03.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user04.png b/Day61-65/code/project_of_tornado/assets/img/user04.png deleted file mode 100644 index c43998c..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user04.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user05.png b/Day61-65/code/project_of_tornado/assets/img/user05.png deleted file mode 100644 index 4125fe2..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user05.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user06.png b/Day61-65/code/project_of_tornado/assets/img/user06.png deleted file mode 100644 index c9f5a08..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user06.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/img/user07.png b/Day61-65/code/project_of_tornado/assets/img/user07.png deleted file mode 100644 index 4a4f3b9..0000000 Binary files a/Day61-65/code/project_of_tornado/assets/img/user07.png and /dev/null differ diff --git a/Day61-65/code/project_of_tornado/assets/js/amazeui.datatables.min.js b/Day61-65/code/project_of_tornado/assets/js/amazeui.datatables.min.js deleted file mode 100644 index e1883da..0000000 --- a/Day61-65/code/project_of_tornado/assets/js/amazeui.datatables.min.js +++ /dev/null @@ -1,3 +0,0 @@ -!function e(t,n,a){function r(i,s){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!s&&l)return l(i,!0);if(o)return o(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[i]={exports:{}};t[i][0].call(c.exports,function(e){var n=t[i][1][e];return r(n?n:e)},c,c.exports,e,t,n,a)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<'am-u-sm-6'f>><'am-g'<'am-u-sm-12'tr>><'am-g am-datatable-footer'<'am-u-sm-5'i><'am-u-sm-7'p>>",renderer:"amazeui"}),a.extend(r.ext.classes,{sWrapper:"dataTables_wrapper am-datatable am-form-inline dt-amazeui",sFilter:"dataTables_filter am-datatable-filter",sFilterInput:"am-form-field am-input-sm",sInfo:"dataTables_info am-datatable-info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length am-form-group am-datatable-length",sLengthSelect:"am-form-select am-input-sm",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled",sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_"}),r.ext.renderer.pageButton.amazeui=function(e,t,n,o,i,s){var l,u,c,f=new r.Api(e),d=e.oClasses,h=e.oLanguage.oPaginate,p=0,g=function(t,r){var o,c,b,v,m=function(e){e.preventDefault(),a(e.currentTarget).hasClass("am-disabled")||f.page(e.data.action).draw(!1)};for(o=0,c=r.length;o0?"":" am-disabled");break;case"previous":l=h.sPrevious,u=v+(i>0?"":" am-disabled");break;case"next":l=h.sNext,u=v+(i",{"class":d.sPageButton+" "+u,id:0===n&&"string"==typeof v?e.sTableId+"_"+v:null}).append(a("",{href:"#","aria-controls":e.sTableId,"data-dt-idx":p,tabindex:e.iTabIndex}).html(l)).appendTo(t),e.oApi._fnBindAction(b,{action:v},m),p++)}};try{c=a(document.activeElement).data("dt-idx")}catch(b){}g(a(t).empty().html('
      ').children("ul"),o),c&&a(t).find("[data-dt-idx="+c+"]").focus()},r.TableTools&&(a.extend(!0,r.TableTools.classes,{container:"DTTT am-btn-group",buttons:{normal:"am-btn am-btn-default",disabled:"am-disabled"},collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:"am-disabled"}},print:{info:"DTTT_print_info"},select:{row:"am-active"}}),a.extend(!0,r.TableTools.DEFAULTS.oTags,{collection:{container:"ul",button:"li",liner:"a"}})),t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{datatables:2}],2:[function(e,t,n){(function(e){!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(e){return a(e,window,document)}):"object"==typeof n?t.exports=function(t,n){return t||(t=window),n||(n="undefined"!=typeof window?"undefined"!=typeof window?window.jQuery:"undefined"!=typeof e?e.jQuery:null:("undefined"!=typeof window?window.jQuery:"undefined"!=typeof e?e.jQuery:null)(t)),a(n,t,t.document)}:a(jQuery,window,document)}(function(e,t,n,a){"use strict";function r(t){var n,a,o="a aa ai ao as b fn i m o s ",i={};e.each(t,function(e,s){n=e.match(/^([^A-Z]+?)([A-Z])/),n&&o.indexOf(n[1]+" ")!==-1&&(a=e.replace(n[0],n[2].toLowerCase()),i[a]=e,"o"===n[1]&&r(t[e]))}),t._hungarianMap=i}function o(t,n,i){t._hungarianMap||r(t);var s;e.each(n,function(r,l){s=t._hungarianMap[r],s===a||!i&&n[s]!==a||("o"===s.charAt(0)?(n[s]||(n[s]={}),e.extend(!0,n[s],n[r]),o(t[s],n[s],i)):n[s]=n[r])})}function i(e){var t=ze.defaults.oLanguage,n=e.sZeroRecords;!e.sEmptyTable&&n&&"No data available in table"===t.sEmptyTable&&je(e,e,"sZeroRecords","sEmptyTable"),!e.sLoadingRecords&&n&&"Loading..."===t.sLoadingRecords&&je(e,e,"sZeroRecords","sLoadingRecords"),e.sInfoThousands&&(e.sThousands=e.sInfoThousands);var a=e.sDecimal;a&&Be(a)}function s(e){pt(e,"ordering","bSort"),pt(e,"orderMulti","bSortMulti"),pt(e,"orderClasses","bSortClasses"),pt(e,"orderCellsTop","bSortCellsTop"),pt(e,"order","aaSorting"),pt(e,"orderFixed","aaSortingFixed"),pt(e,"paging","bPaginate"),pt(e,"pagingType","sPaginationType"),pt(e,"pageLength","iDisplayLength"),pt(e,"searching","bFilter"),"boolean"==typeof e.sScrollX&&(e.sScrollX=e.sScrollX?"100%":""),"boolean"==typeof e.scrollX&&(e.scrollX=e.scrollX?"100%":"");var t=e.aoSearchCols;if(t)for(var n=0,a=t.length;n").css({position:"fixed",top:0,left:0,height:1,width:1,overflow:"hidden"}).append(e("
      ").css({position:"absolute",top:1,left:1,width:100,overflow:"scroll"}).append(e("
      ").css({width:"100%",height:10}))).appendTo("body"),r=a.children(),o=r.children();n.barWidth=r[0].offsetWidth-r[0].clientWidth,n.bScrollOversize=100===o[0].offsetWidth&&100!==r[0].clientWidth,n.bScrollbarLeft=1!==Math.round(o.offset().left),n.bBounding=!!a[0].getBoundingClientRect().width,a.remove()}e.extend(t.oBrowser,ze.__browser),t.oScroll.iBarWidth=ze.__browser.barWidth}function c(e,t,n,r,o,i){var s,l=r,u=!1;for(n!==a&&(s=n,u=!0);l!==o;)e.hasOwnProperty(l)&&(s=u?t(s,e[l],l,e):e[l],u=!0,l+=i);return s}function f(t,a){var r=ze.defaults.column,o=t.aoColumns.length,i=e.extend({},ze.models.oColumn,r,{nTh:a?a:n.createElement("th"),sTitle:r.sTitle?r.sTitle:a?a.innerHTML:"",aDataSort:r.aDataSort?r.aDataSort:[o],mData:r.mData?r.mData:o,idx:o});t.aoColumns.push(i);var s=t.aoPreSearchCols;s[o]=e.extend({},ze.models.oSearch,s[o]),d(t,o,e(a).data())}function d(t,n,r){var i=t.aoColumns[n],s=t.oClasses,u=e(i.nTh);if(!i.sWidthOrig){i.sWidthOrig=u.attr("width")||null;var c=(u.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);c&&(i.sWidthOrig=c[1])}r!==a&&null!==r&&(l(r),o(ze.defaults.column,r),r.mDataProp===a||r.mData||(r.mData=r.mDataProp),r.sType&&(i._sManualType=r.sType),r.className&&!r.sClass&&(r.sClass=r.className),e.extend(i,r),je(i,r,"sWidth","sWidthOrig"),r.iDataSort!==a&&(i.aDataSort=[r.iDataSort]),je(i,r,"aDataSort"));var f=i.mData,d=I(f),h=i.mRender?I(i.mRender):null,p=function(e){return"string"==typeof e&&e.indexOf("@")!==-1};i._bAttrSrc=e.isPlainObject(f)&&(p(f.sort)||p(f.type)||p(f.filter)),i._setter=null,i.fnGetData=function(e,t,n){var r=d(e,t,a,n);return h&&t?h(r,t,e,n):r},i.fnSetData=function(e,t,n){return A(f)(e,t,n)},"number"!=typeof f&&(t._rowReadObject=!0),t.oFeatures.bSort||(i.bSortable=!1,u.addClass(s.sSortableNone));var g=e.inArray("asc",i.asSorting)!==-1,b=e.inArray("desc",i.asSorting)!==-1;i.bSortable&&(g||b)?g&&!b?(i.sSortingClass=s.sSortableAsc,i.sSortingClassJUI=s.sSortJUIAscAllowed):!g&&b?(i.sSortingClass=s.sSortableDesc,i.sSortingClassJUI=s.sSortJUIDescAllowed):(i.sSortingClass=s.sSortable,i.sSortingClassJUI=s.sSortJUI):(i.sSortingClass=s.sSortableNone,i.sSortingClassJUI="")}function h(e){if(e.oFeatures.bAutoWidth!==!1){var t=e.aoColumns;ve(e);for(var n=0,a=t.length;n=0;i--){h=n[i];var g=h.targets!==a?h.targets:h.aTargets;for(e.isArray(g)||(g=[g]),l=0,u=g.length;l=0){for(;p.length<=g[l];)f(t);o(g[l],h)}else if("number"==typeof g[l]&&g[l]<0)o(p.length+g[l],h);else if("string"==typeof g[l])for(c=0,d=p.length;ct&&e[o]--;r!=-1&&n===a&&e.splice(r,1)}function R(e,t,n,r){var o,i,s=e.aoData[t],l=function(n,a){for(;n.childNodes.length;)n.removeChild(n.firstChild);n.innerHTML=w(e,t,a,"display")};if("dom"!==n&&(n&&"auto"!==n||"dom"!==s.src)){var u=s.anCells;if(u)if(r!==a)l(u[r],r);else for(o=0,i=u.length;o").appendTo(s)),n=0,a=f.length;ntr").attr("role","row"),e(s).find(">tr>th, >tr>td").addClass(c.sHeaderTH),e(l).find(">tr>th, >tr>td").addClass(c.sFooterTH),null!==l){var d=t.aoFooter[0];for(n=0,a=d.length;n=0;s--)t.aoColumns[s].bVisible||r||p[o].splice(s,1);g.push([])}for(o=0,i=p.length;o=t.fnRecordsDisplay()?0:u,t.iInitDisplayStart=-1);var d=t._iDisplayStart,h=t.fnDisplayEnd();if(t.bDeferLoading)t.bDeferLoading=!1,t.iDraw++,he(t,!1);else if(c){if(!t.bDestroying&&!V(t))return}else t.iDraw++;if(0!==f.length)for(var p=c?0:d,g=c?t.aoData.length:h,v=p;v",{"class":s?i[0]:""}).append(e("",{valign:"top",colSpan:b(t),"class":t.oClasses.sRowEmpty}).html(_))[0]}ke(t,"aoHeaderCallback","header",[e(t.nTHead).children("tr")[0],F(t),d,h,f]),ke(t,"aoFooterCallback","footer",[e(t.nTFoot).children("tr")[0],F(t),d,h,f]);var T=e(t.nTBody);T.children().detach(),T.append(e(r)),ke(t,"aoDrawCallback","draw",[t]),t.bSorted=!1,t.bFiltered=!1,t.bDrawing=!1}function W(e,t){var n=e.oFeatures,a=n.bSort,r=n.bFilter;a&&Te(e),r?$(e,e.oPreviousSearch):e.aiDisplay=e.aiDisplayMaster.slice(),t!==!0&&(e._iDisplayStart=0),e._drawHold=t,M(e),e._drawHold=!1}function U(t){var n=t.oClasses,a=e(t.nTable),r=e("
      ").insertBefore(a),o=t.oFeatures,i=e("
      ",{id:t.sTableId+"_wrapper","class":n.sWrapper+(t.nTFoot?"":" "+n.sNoFooter)});t.nHolding=r[0],t.nTableWrapper=i[0],t.nTableReinsertBefore=t.nTable.nextSibling;for(var s,l,u,c,f,d,h=t.sDom.split(""),p=0;p")[0],c=h[p+1],"'"==c||'"'==c){for(f="",d=2;h[p+d]!=c;)f+=h[p+d],d++;if("H"==f?f=n.sJUIHeader:"F"==f&&(f=n.sJUIFooter),f.indexOf(".")!=-1){var g=f.split(".");u.id=g[0].substr(1,g[0].length-1),u.className=g[1]}else"#"==f.charAt(0)?u.id=f.substr(1,f.length-1):u.className=f;p+=d}i.append(u),i=e(u)}else if(">"==l)i=i.parent();else if("l"==l&&o.bPaginate&&o.bLengthChange)s=ue(t);else if("f"==l&&o.bFilter)s=z(t);else if("r"==l&&o.bProcessing)s=de(t);else if("t"==l)s=pe(t);else if("i"==l&&o.bInfo)s=ae(t);else if("p"==l&&o.bPaginate)s=ce(t);else if(0!==ze.ext.feature.length)for(var b=ze.ext.feature,v=0,m=b.length;v',u=o.sSearch;u=u.match(/_INPUT_/)?u.replace("_INPUT_",l):u+l;var c=e("
      ",{id:s.f?null:r+"_filter","class":a.sFilter}).append(e("
      ").addClass(n.sLength);return t.aanFeatures.l||(f[0].id=a+"_length"),f.children().append(t.oLanguage.sLengthMenu.replace("_MENU_",l[0].outerHTML)),e("select",f).val(t._iDisplayLength).bind("change.DT",function(n){le(t,e(this).val()),M(t)}),e(t.nTable).bind("length.dt.DT",function(n,a,r){t===a&&e("select",f).val(r)}),f[0]}function ce(t){var n=t.sPaginationType,a=ze.ext.pager[n],r="function"==typeof a,o=function(e){M(e)},i=e("
      ").addClass(t.oClasses.sPaging+n)[0],s=t.aanFeatures;return r||a.fnInit(t,i,o),s.p||(i.id=t.sTableId+"_paginate",t.aoDrawCallback.push({fn:function(e){if(r){var t,n,i=e._iDisplayStart,l=e._iDisplayLength,u=e.fnRecordsDisplay(),c=l===-1,f=c?0:Math.ceil(i/l),d=c?1:Math.ceil(u/l),h=a(f,d);for(t=0,n=s.p.length;to&&(a=0)):"first"==t?a=0:"previous"==t?(a=r>=0?a-r:0,a<0&&(a=0)):"next"==t?a+r",{id:t.aanFeatures.r?null:t.sTableId+"_processing","class":t.oClasses.sProcessing}).html(t.oLanguage.sProcessing).insertBefore(t.nTable)[0]}function he(t,n){t.oFeatures.bProcessing&&e(t.aanFeatures.r).css("display",n?"block":"none"),ke(t,null,"processing",[t,n])}function pe(t){var n=e(t.nTable);n.attr("role","grid");var a=t.oScroll;if(""===a.sX&&""===a.sY)return t.nTable;var r=a.sX,o=a.sY,i=t.oClasses,s=n.children("caption"),l=s.length?s[0]._captionSide:null,u=e(n[0].cloneNode(!1)),c=e(n[0].cloneNode(!1)),f=n.children("tfoot"),d="
      ",h=function(e){return e?ye(e):null};f.length||(f=null);var p=e(d,{"class":i.sScrollWrapper}).append(e(d,{"class":i.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,width:r?h(r):"100%"}).append(e(d,{"class":i.sScrollHeadInner}).css({"box-sizing":"content-box",width:a.sXInner||"100%"}).append(u.removeAttr("id").css("margin-left",0).append("top"===l?s:null).append(n.children("thead"))))).append(e(d,{"class":i.sScrollBody}).css({position:"relative",overflow:"auto",width:h(r)}).append(n));f&&p.append(e(d,{"class":i.sScrollFoot}).css({overflow:"hidden",border:0,width:r?h(r):"100%"}).append(e(d,{"class":i.sScrollFootInner}).append(c.removeAttr("id").css("margin-left",0).append("bottom"===l?s:null).append(n.children("tfoot")))));var g=p.children(),b=g[0],v=g[1],m=f?g[2]:null;return r&&e(v).on("scroll.DT",function(e){var t=this.scrollLeft;b.scrollLeft=t,f&&(m.scrollLeft=t)}),e(v).css(o&&a.bCollapse?"max-height":"height",o),t.nScrollHead=b,t.nScrollBody=v,t.nScrollFoot=m,t.aoDrawCallback.push({fn:ge,sName:"scrolling"}),p[0]}function ge(t){var n,r,o,i,s,l,u,c,f,d=t.oScroll,g=d.sX,b=d.sXInner,v=d.sY,m=d.iBarWidth,S=e(t.nScrollHead),D=S[0].style,y=S.children("div"),_=y[0].style,T=y.children("table"),w=t.nScrollBody,C=e(w),x=w.style,I=e(t.nScrollFoot),A=I.children("div"),F=A.children("table"),L=e(t.nTHead),P=e(t.nTable),R=P[0],j=R.style,H=t.nTFoot?e(t.nTFoot):null,N=t.oBrowser,O=N.bScrollOversize,k=lt(t.aoColumns,"nTh"),M=[],W=[],U=[],E=[],J=function(e){var t=e.style;t.paddingTop="0",t.paddingBottom="0",t.borderTopWidth="0",t.borderBottomWidth="0",t.height=0},V=w.scrollHeight>w.clientHeight;if(t.scrollBarVis!==V&&t.scrollBarVis!==a)return t.scrollBarVis=V,void h(t);t.scrollBarVis=V,P.children("thead, tfoot").remove(),H&&(l=H.clone().prependTo(P),r=H.find("tr"),i=l.find("tr")),s=L.clone().prependTo(P),n=L.find("tr"),o=s.find("tr"),s.find("th, td").removeAttr("tabindex"),g||(x.width="100%",S[0].style.width="100%"),e.each(B(t,s),function(e,n){u=p(t,e),n.style.width=t.aoColumns[u].sWidth}),H&&be(function(e){e.style.width=""},i),f=P.outerWidth(),""===g?(j.width="100%",O&&(P.find("tbody").height()>w.offsetHeight||"scroll"==C.css("overflow-y"))&&(j.width=ye(P.outerWidth()-m)),f=P.outerWidth()):""!==b&&(j.width=ye(b),f=P.outerWidth()),be(J,o),be(function(t){U.push(t.innerHTML),M.push(ye(e(t).css("width")))},o),be(function(t,n){e.inArray(t,k)!==-1&&(t.style.width=M[n])},n),e(o).height(0),H&&(be(J,i),be(function(t){E.push(t.innerHTML),W.push(ye(e(t).css("width")))},i),be(function(e,t){e.style.width=W[t]},r),e(i).height(0)),be(function(e,t){e.innerHTML='
      '+U[t]+"
      ",e.style.width=M[t]},o),H&&be(function(e,t){e.innerHTML='
      '+E[t]+"
      ",e.style.width=W[t]},i),P.outerWidth()w.offsetHeight||"scroll"==C.css("overflow-y")?f+m:f,O&&(w.scrollHeight>w.offsetHeight||"scroll"==C.css("overflow-y"))&&(j.width=ye(c-m)),""!==g&&""===b||Re(t,1,"Possible column misalignment",6)):c="100%",x.width=ye(c),D.width=ye(c),H&&(t.nScrollFoot.style.width=ye(c)),v||O&&(x.height=ye(R.offsetHeight+m));var X=P.outerWidth();T[0].style.width=ye(X),_.width=ye(X);var q=P.height()>w.clientHeight||"scroll"==C.css("overflow-y"),G="padding"+(N.bScrollbarLeft?"Left":"Right"); -_[G]=q?m+"px":"0px",H&&(F[0].style.width=ye(X),A[0].style.width=ye(X),A[0].style[G]=q?m+"px":"0px"),P.children("colgroup").insertBefore(P.children("thead")),C.scroll(),!t.bSorted&&!t.bFiltered||t._drawHold||(w.scrollTop=0)}function be(e,t,n){for(var a,r,o=0,i=0,s=t.length;i").appendTo(x.find("tbody"));for(x.find("thead, tfoot").remove(),x.append(e(n.nTHead).clone()).append(e(n.nTFoot).clone()),x.find("tfoot th, tfoot td").css("width",""),m=B(n,x.find("thead")[0]),a=0;a").css({width:r.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(n.aoData.length)for(a=0;a").css(c||u?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(x).appendTo(D);c&&f?x.width(f):c?(x.css("width","auto"),x.removeAttr("width"),x.width()").css("width",ye(t)).appendTo(a||n.body),o=r[0].offsetWidth;return r.remove(),o}function Se(t,n){var a=De(t,n);if(a<0)return null;var r=t.aoData[a];return r.nTr?r.anCells[n]:e("").html(w(t,a,n,"display"))[0]}function De(e,t){for(var n,a=-1,r=-1,o=0,i=e.aoData.length;oa&&(a=n.length,r=o);return r}function ye(e){return null===e?"0px":"number"==typeof e?e<0?"0px":e+"px":e.match(/\d$/)?e+"px":e}function _e(t){var n,r,o,i,s,l,u,c=[],f=t.aoColumns,d=t.aaSortingFixed,h=e.isPlainObject(d),p=[],g=function(t){t.length&&!e.isArray(t[0])?p.push(t):e.merge(p,t)};for(e.isArray(d)&&g(d),h&&d.pre&&g(d.pre),g(t.aaSorting),h&&d.post&&g(d.post),n=0;na?1:0,0!==s)return"asc"===u.dir?s:-s;return n=i[e],a=i[t],na?1:0}):c.sort(function(e,t){var n,a,r,u,c,f,d=o.length,h=l[e]._aSortData,p=l[t]._aSortData;for(r=0;ra?1:0})}e.bSorted=!0}function we(e){for(var t,n,a=e.aoColumns,r=_e(e),o=e.oLanguage.oAria,i=0,s=a.length;i/g,""),f=l.nTh;f.removeAttribute("aria-sort"),l.bSortable?(r.length>0&&r[0].col==i?(f.setAttribute("aria-sort","asc"==r[0].dir?"ascending":"descending"),n=u[r[0].index+1]||u[0]):n=u[0],t=c+("asc"===n?o.sSortAscending:o.sSortDescending)):t=c,f.setAttribute("aria-label",t)}}function Ce(t,n,r,o){var i,s=t.aoColumns[n],l=t.aaSorting,u=s.asSorting,c=function(t,n){var r=t._idx;return r===a&&(r=e.inArray(t[1],u)),r+10&&s.time<+new Date-1e3*u)&&i.length===s.columns.length){for(t.oLoadedState=e.extend(!0,{},s),s.start!==a&&(t._iDisplayStart=s.start,t.iInitDisplayStart=s.start),s.length!==a&&(t._iDisplayLength=s.length),s.order!==a&&(t.aaSorting=[],e.each(s.order,function(e,n){t.aaSorting.push(n[0]>=i.length?[0,n[1]]:n)})),s.search!==a&&e.extend(t.oPreviousSearch,ne(s.search)),r=0,o=s.columns.length;r=n&&(t=n-a),t-=t%a,(a===-1||t<0)&&(t=0),e._iDisplayStart=t}function We(t,n){var a=t.renderer,r=ze.ext.renderer[n];return e.isPlainObject(a)&&a[n]?r[a[n]]||r._:"string"==typeof a?r[a]||r._:r._}function Ue(e){return e.oFeatures.bServerSide?"ssp":e.ajax||e.sAjaxSource?"ajax":"dom"}function Ee(e,t){var n=[],a=Vt.numbers_length,r=Math.floor(a/2);return t<=a?n=ct(0,t):e<=r?(n=ct(0,a-2),n.push("ellipsis"),n.push(t-1)):e>=t-1-r?(n=ct(t-(a-2),t),n.splice(0,0,"ellipsis"),n.splice(0,0,0)):(n=ct(e-r+2,e+r-1),n.push("ellipsis"),n.push(t-1),n.splice(0,0,"ellipsis"),n.splice(0,0,0)),n.DT_el="span",n}function Be(t){e.each({num:function(e){return Xt(e,t)},"num-fmt":function(e){return Xt(e,t,tt)},"html-num":function(e){return Xt(e,t,Ye)},"html-num-fmt":function(e){return Xt(e,t,Ye,tt)}},function(e,n){Ve.type.order[e+t+"-pre"]=n,e.match(/^html\-/)&&(Ve.type.search[e+t]=Ve.type.search.html)})}function Je(e){return function(){var t=[Pe(this[ze.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return ze.ext.internal[e].apply(this,t)}}var Ve,Xe,qe,Ge,ze=function(t){this.$=function(e,t){return this.api(!0).$(e,t)},this._=function(e,t){return this.api(!0).rows(e,t).data()},this.api=function(e){return new Xe(e?Pe(this[Ve.iApiIndex]):this)},this.fnAddData=function(t,n){var r=this.api(!0),o=e.isArray(t)&&(e.isArray(t[0])||e.isPlainObject(t[0]))?r.rows.add(t):r.row.add(t);return(n===a||n)&&r.draw(),o.flatten().toArray()},this.fnAdjustColumnSizing=function(e){var t=this.api(!0).columns.adjust(),n=t.settings()[0],r=n.oScroll;e===a||e?t.draw(!1):""===r.sX&&""===r.sY||ge(n)},this.fnClearTable=function(e){var t=this.api(!0).clear();(e===a||e)&&t.draw()},this.fnClose=function(e){this.api(!0).row(e).child.hide()},this.fnDeleteRow=function(e,t,n){var r=this.api(!0),o=r.rows(e),i=o.settings()[0],s=i.aoData[o[0][0]];return o.remove(),t&&t.call(this,i,s),(n===a||n)&&r.draw(),s},this.fnDestroy=function(e){this.api(!0).destroy(e)},this.fnDraw=function(e){this.api(!0).draw(e)},this.fnFilter=function(e,t,n,r,o,i){var s=this.api(!0);null===t||t===a?s.search(e,n,r,i):s.column(t).search(e,n,r,i),s.draw()},this.fnGetData=function(e,t){var n=this.api(!0);if(e!==a){var r=e.nodeName?e.nodeName.toLowerCase():"";return t!==a||"td"==r||"th"==r?n.cell(e,t).data():n.row(e).data()||null}return n.data().toArray()},this.fnGetNodes=function(e){var t=this.api(!0);return e!==a?t.row(e).node():t.rows().nodes().flatten().toArray()},this.fnGetPosition=function(e){var t=this.api(!0),n=e.nodeName.toUpperCase();if("TR"==n)return t.row(e).index();if("TD"==n||"TH"==n){var a=t.cell(e).index();return[a.row,a.columnVisible,a.column]}return null},this.fnIsOpen=function(e){return this.api(!0).row(e).child.isShown()},this.fnOpen=function(e,t,n){return this.api(!0).row(e).child(t,n).show().child()[0]},this.fnPageChange=function(e,t){var n=this.api(!0).page(e);(t===a||t)&&n.draw(!1)},this.fnSetColumnVis=function(e,t,n){var r=this.api(!0).column(e).visible(t);(n===a||n)&&r.columns.adjust().draw()},this.fnSettings=function(){return Pe(this[Ve.iApiIndex])},this.fnSort=function(e){this.api(!0).order(e).draw()},this.fnSortListener=function(e,t,n){this.api(!0).order.listener(e,t,n)},this.fnUpdate=function(e,t,n,r,o){var i=this.api(!0);return n===a||null===n?i.row(t).data(e):i.cell(t,n).data(e),(o===a||o)&&i.columns.adjust(),(r===a||r)&&i.draw(),0},this.fnVersionCheck=Ve.fnVersionCheck;var n=this,r=t===a,c=this.length;r&&(t={}),this.oApi=this.internal=Ve.internal;for(var h in ze.ext.internal)h&&(this[h]=Je(h));return this.each(function(){var h,p={},g=c>1?He(p,t,!0):t,b=0,v=this.getAttribute("id"),m=!1,_=ze.defaults,T=e(this);if("table"!=this.nodeName.toLowerCase())return void Re(null,0,"Non-table node initialisation ("+this.nodeName+")",2);s(_),l(_.column),o(_,_,!0),o(_.column,_.column,!0),o(_,e.extend(g,T.data()));var w=ze.settings;for(b=0,h=w.length;bt<"F"ip>'),F.renderer?e.isPlainObject(F.renderer)&&!F.renderer.header&&(F.renderer.header="jqueryui"):F.renderer="jqueryui"):e.extend(L,ze.ext.classes,g.oClasses),T.addClass(L.sTable),F.iInitDisplayStart===a&&(F.iInitDisplayStart=g.iDisplayStart,F._iDisplayStart=g.iDisplayStart),null!==g.iDeferLoading){F.bDeferLoading=!0;var P=e.isArray(g.iDeferLoading);F._iRecordsDisplay=P?g.iDeferLoading[0]:g.iDeferLoading,F._iRecordsTotal=P?g.iDeferLoading[1]:g.iDeferLoading}var R=F.oLanguage;e.extend(!0,R,g.oLanguage),""!==R.sUrl&&(e.ajax({dataType:"json",url:R.sUrl,success:function(t){i(t),o(_.oLanguage,t),e.extend(!0,R,t),ie(F)},error:function(){ie(F)}}),m=!0),null===g.asStripeClasses&&(F.asStripeClasses=[L.sStripeOdd,L.sStripeEven]);var j=F.asStripeClasses,H=T.children("tbody").find("tr").eq(0);e.inArray(!0,e.map(j,function(e,t){return H.hasClass(e)}))!==-1&&(e("tbody tr",this).removeClass(j.join(" ")),F.asDestroyStripes=j.slice());var N,O=[],k=this.getElementsByTagName("thead");if(0!==k.length&&(E(F.aoHeader,k[0]),O=B(F)),null===g.aoColumns)for(N=[],b=0,h=O.length;b").appendTo(this)),F.nTHead=V[0];var X=T.children("tbody");0===X.length&&(X=e("").appendTo(this)),F.nTBody=X[0];var q=T.children("tfoot");if(0===q.length&&J.length>0&&(""!==F.oScroll.sX||""!==F.oScroll.sY)&&(q=e("").appendTo(this)),0===q.length||0===q.children().length?T.addClass(L.sNoFooter):q.length>0&&(F.nTFoot=q[0],E(F.aoFooter,F.nTFoot)),g.aaData)for(b=0;b/g,Ze=/^[\w\+\-]/,Ke=/[\w\+\-]$/,et=new RegExp("(\\"+["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^","-"].join("|\\")+")","g"),tt=/[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi,nt=function(e){return!e||e===!0||"-"===e},at=function(e){var t=parseInt(e,10);return!isNaN(t)&&isFinite(e)?t:null},rt=function(e,t){return $e[t]||($e[t]=new RegExp(vt(t),"g")),"string"==typeof e&&"."!==t?e.replace(/\./g,"").replace($e[t],"."):e},ot=function(e,t,n){var a="string"==typeof e;return!!nt(e)||(t&&a&&(e=rt(e,t)),n&&a&&(e=e.replace(tt,"")),!isNaN(parseFloat(e))&&isFinite(e))},it=function(e){return nt(e)||"string"==typeof e},st=function(e,t,n){if(nt(e))return!0;var a=it(e);return a?!!ot(dt(e),t,n)||null:null},lt=function(e,t,n){var r=[],o=0,i=e.length;if(n!==a)for(;o")[0],St=mt.textContent!==a,Dt=/<.*?>/g,yt=ze.util.throttle,_t=[],Tt=Array.prototype,wt=function(t){var n,a,r=ze.settings,o=e.map(r,function(e,t){return e.nTable});return t?t.nTable&&t.oApi?[t]:t.nodeName&&"table"===t.nodeName.toLowerCase()?(n=e.inArray(t,o),n!==-1?[r[n]]:null):t&&"function"==typeof t.settings?t.settings().toArray():("string"==typeof t?a=e(t):t instanceof e&&(a=t),a?a.map(function(t){return n=e.inArray(this,o),n!==-1?r[n]:null}).toArray():void 0):[]};Xe=function(t,n){if(!(this instanceof Xe))return new Xe(t,n);var a=[],r=function(e){var t=wt(e);t&&(a=a.concat(t))};if(e.isArray(t))for(var o=0,i=t.length;oe?new Xe(t[e],this[e]):null},filter:function(e){var t=[];if(Tt.filter)t=Tt.filter.call(this,e,this);else for(var n=0,a=this.length;n0)return e[0].json}),qe("ajax.params()",function(){var e=this.context;if(e.length>0)return e[0].oAjaxData}),qe("ajax.reload()",function(e,t){return this.iterator("table",function(n){xt(n,t===!1,e)})}),qe("ajax.url()",function(t){var n=this.context;return t===a?0===n.length?a:(n=n[0],n.ajax?e.isPlainObject(n.ajax)?n.ajax.url:n.ajax:n.sAjaxSource):this.iterator("table",function(n){e.isPlainObject(n.ajax)?n.ajax.url=t:n.ajax=t})}),qe("ajax.url().load()",function(e,t){return this.iterator("table",function(n){xt(n,t===!1,e)})});var It=function(t,n,r,o,i){var s,l,u,c,f,d,h=[],p=typeof n;for(n&&"string"!==p&&"function"!==p&&n.length!==a||(n=[n]),u=0,c=n.length;u0)return e[0]=e[t],e[0].length=1,e.length=1,e.context=[e.context[t]],e;return e.length=0,e},Lt=function(t,n){var a,r,o,i=[],s=t.aiDisplay,l=t.aiDisplayMaster,u=n.search,c=n.order,f=n.page;if("ssp"==Ue(t))return"removed"===u?[]:ct(0,l.length);if("current"==f)for(a=t._iDisplayStart,r=t.fnDisplayEnd();a=0&&"applied"==u)&&i.push(a));return i},Pt=function(t,n,r){var o=function(n){var o=at(n);if(null!==o&&!r)return[o];var i=Lt(t,r);if(null!==o&&e.inArray(o,i)!==-1)return[o];if(!n)return i;if("function"==typeof n)return e.map(i,function(e){var a=t.aoData[e];return n(e,a._aData,a.nTr)?e:null});var s=ft(ut(t.aoData,i,"nTr"));if(n.nodeName){if(n._DT_RowIndex!==a)return[n._DT_RowIndex];if(n._DT_CellIndex)return[n._DT_CellIndex.row];var l=e(n).closest("*[data-dt-row]");return l.length?[l.data("dt-row")]:[]}if("string"==typeof n&&"#"===n.charAt(0)){var u=t.aIds[n.replace(/^#/,"")];if(u!==a)return[u.idx]}return e(s).filter(n).map(function(){return this._DT_RowIndex}).toArray()};return It("row",n,o,t,r)};qe("rows()",function(t,n){t===a?t="":e.isPlainObject(t)&&(n=t,t=""),n=At(n);var r=this.iterator("table",function(e){return Pt(e,t,n)},1);return r.selector.rows=t,r.selector.opts=n,r}),qe("rows().nodes()",function(){return this.iterator("row",function(e,t){return e.aoData[t].nTr||a},1)}),qe("rows().data()",function(){return this.iterator(!0,"rows",function(e,t){return ut(e.aoData,t,"_aData")},1)}),Ge("rows().cache()","row().cache()",function(e){return this.iterator("row",function(t,n){var a=t.aoData[n];return"search"===e?a._aFilterData:a._aSortData},1)}),Ge("rows().invalidate()","row().invalidate()",function(e){return this.iterator("row",function(t,n){R(t,n,e)})}),Ge("rows().indexes()","row().index()",function(){return this.iterator("row",function(e,t){return t},1)}),Ge("rows().ids()","row().id()",function(e){for(var t=[],n=this.context,a=0,r=n.length;a").addClass(a);e("td",l).addClass(a).html(n)[0].colSpan=b(t),o.push(l[0])}};i(a,r),n._details&&n._details.remove(),n._details=e(o),n._detailsShow&&n._details.insertAfter(n.nTr)},jt=function(e,t){var n=e.context;if(n.length){var r=n[0].aoData[t!==a?t:e[0]];r&&r._details&&(r._details.remove(),r._detailsShow=a,r._details=a)}},Ht=function(e,t){var n=e.context;if(n.length&&e.length){var a=n[0].aoData[e[0]];a._details&&(a._detailsShow=t,t?a._details.insertAfter(a.nTr):a._details.detach(),Nt(n[0]))}},Nt=function(e){var t=new Xe(e),n=".dt.DT_details",a="draw"+n,r="column-visibility"+n,o="destroy"+n,i=e.aoData;t.off(a+" "+r+" "+o),lt(i,"_details").length>0&&(t.on(a,function(n,a){e===a&&t.rows({page:"current"}).eq(0).each(function(e){var t=i[e];t._detailsShow&&t._details.insertAfter(t.nTr)})}),t.on(r,function(t,n,a,r){if(e===n)for(var o,s=b(n),l=0,u=i.length;l=0?s:r.length+s];if("function"==typeof n){var l=Lt(t,a);return e.map(r,function(e,a){return n(a,Ut(t,a,0,0,l),i[a])?a:null})}var u="string"==typeof n?n.match(Wt):"";if(u)switch(u[2]){case"visIdx":case"visible":var c=parseInt(u[1],10);if(c<0){var f=e.map(r,function(e,t){return e.bVisible?t:null});return[f[f.length+c]]}return[p(t,c)];case"name":return e.map(o,function(e,t){return e===u[1]?t:null; -});default:return[]}if(n.nodeName&&n._DT_CellIndex)return[n._DT_CellIndex.column];var d=e(i).filter(n).map(function(){return e.inArray(this,i)}).toArray();if(d.length||!n.nodeName)return d;var h=e(n).closest("*[data-dt-column]");return h.length?[h.data("dt-column")]:[]};return It("column",n,s,t,a)},Bt=function(t,n,r){var o,i,s,l,u=t.aoColumns,c=u[n],f=t.aoData;if(r===a)return c.bVisible;if(c.bVisible!==r){if(r){var d=e.inArray(!0,lt(u,"bVisible"),n+1);for(i=0,s=f.length;in;return!0},ze.isDataTable=ze.fnIsDataTable=function(t){var n=e(t).get(0),a=!1;return e.each(ze.settings,function(t,r){var o=r.nScrollHead?e("table",r.nScrollHead)[0]:null,i=r.nScrollFoot?e("table",r.nScrollFoot)[0]:null;r.nTable!==n&&o!==n&&i!==n||(a=!0)}),a},ze.tables=ze.fnTables=function(t){var n=!1;e.isPlainObject(t)&&(n=t.api,t=t.visible);var a=e.map(ze.settings,function(n){if(!t||t&&e(n.nTable).is(":visible"))return n.nTable});return n?new Xe(a):a},ze.camelToHungarian=o,qe("$()",function(t,n){var a=this.rows(n).nodes(),r=e(a);return e([].concat(r.filter(t).toArray(),r.find(t).toArray()))}),e.each(["on","one","off"],function(t,n){qe(n+"()",function(){var t=Array.prototype.slice.call(arguments);t[0].match(/\.dt\b/)||(t[0]+=".dt");var a=e(this.tables().nodes());return a[n].apply(a,t),this})}),qe("clear()",function(){return this.iterator("table",function(e){L(e)})}),qe("settings()",function(){return new Xe(this.context,this.context)}),qe("init()",function(){var e=this.context;return e.length?e[0].oInit:null}),qe("data()",function(){return this.iterator("table",function(e){return lt(e.aoData,"_aData")}).flatten()}),qe("destroy()",function(n){return n=n||!1,this.iterator("table",function(a){var r,o=a.nTableWrapper.parentNode,i=a.oClasses,s=a.nTable,l=a.nTBody,u=a.nTHead,c=a.nTFoot,f=e(s),d=e(l),h=e(a.nTableWrapper),p=e.map(a.aoData,function(e){return e.nTr});a.bDestroying=!0,ke(a,"aoDestroyCallback","destroy",[a]),n||new Xe(a).columns().visible(!0),h.unbind(".DT").find(":not(tbody *)").unbind(".DT"),e(t).unbind(".DT-"+a.sInstance),s!=u.parentNode&&(f.children("thead").detach(),f.append(u)),c&&s!=c.parentNode&&(f.children("tfoot").detach(),f.append(c)),a.aaSorting=[],a.aaSortingFixed=[],Ie(a),e(p).removeClass(a.asStripeClasses.join(" ")),e("th, td",u).removeClass(i.sSortable+" "+i.sSortableAsc+" "+i.sSortableDesc+" "+i.sSortableNone),a.bJUI&&(e("th span."+i.sSortIcon+", td span."+i.sSortIcon,u).detach(),e("th, td",u).each(function(){var t=e("div."+i.sSortJUIWrapper,this);e(this).append(t.contents()),t.detach()})),d.children().detach(),d.append(p);var g=n?"remove":"detach";f[g](),h[g](),!n&&o&&(o.insertBefore(s,a.nTableReinsertBefore),f.css("width",a.sDestroyWidth).removeClass(i.sTable),r=a.asDestroyStripes.length,r&&d.children().each(function(t){e(this).addClass(a.asDestroyStripes[t%r])}));var b=e.inArray(a,ze.settings);b!==-1&&ze.settings.splice(b,1)})}),e.each(["column","row","cell"],function(e,t){qe(t+"s().every()",function(e){var n=this.selector.opts,r=this;return this.iterator(t,function(o,i,s,l,u){e.call(r[t](i,"cell"===t?s:n,"cell"===t?n:a),i,s,l,u)})})}),qe("i18n()",function(t,n,r){var o=this.context[0],i=I(t)(o.oLanguage);return i===a&&(i=n),r!==a&&e.isPlainObject(i)&&(i=i[r]!==a?i[r]:i._),i.replace("%d",r)}),ze.version="1.10.12",ze.settings=[],ze.models={},ze.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0},ze.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null,idx:-1},ze.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null},ze.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bJQueryUI:!1,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null,fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(e){try{return JSON.parse((e.iStateDuration===-1?sessionStorage:localStorage).getItem("DataTables_"+e.sInstance+"_"+location.pathname))}catch(t){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(e,t){try{(e.iStateDuration===-1?sessionStorage:localStorage).setItem("DataTables_"+e.sInstance+"_"+location.pathname,JSON.stringify(t))}catch(n){}},fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"},oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)",sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:e.extend({},ze.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"},r(ze.defaults),ze.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null},r(ze.defaults.column),ze.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[],aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button",iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:a,oAjaxData:a,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,bJUI:null,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==Ue(this)?1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==Ue(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var e=this._iDisplayLength,t=this._iDisplayStart,n=t+e,a=this.aiDisplay.length,r=this.oFeatures,o=r.bPaginate;return r.bServerSide?o===!1||e===-1?t+a:Math.min(t+e,this._iRecordsDisplay):!o||n>a||e===-1?a:n},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null},ze.ext=Ve={buttons:{},classes:{},builder:"-source-",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:ze.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:ze.version},e.extend(Ve,{afnFiltering:Ve.search,aTypes:Ve.type.detect,ofnSearch:Ve.type.search,oSort:Ve.type.order,afnSortData:Ve.order,aoFeatures:Ve.feature,oApi:Ve.internal,oStdClasses:Ve.classes,oPagination:Ve.pager}),e.extend(ze.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled",sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"",sJUIHeader:"",sJUIFooter:""}),function(){var t="";t="";var n=t+"ui-state-default",a=t+"css_right ui-icon ui-icon-",r=t+"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix";e.extend(ze.ext.oJUIClasses,ze.ext.classes,{sPageButton:"fg-button ui-button "+n,sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",sSortAsc:n+" sorting_asc",sSortDesc:n+" sorting_desc",sSortable:n+" sorting",sSortableAsc:n+" sorting_asc_disabled",sSortableDesc:n+" sorting_desc_disabled",sSortableNone:n+" sorting_disabled",sSortJUIAsc:a+"triangle-1-n",sSortJUIDesc:a+"triangle-1-s",sSortJUI:a+"carat-2-n-s",sSortJUIAscAllowed:a+"carat-1-n",sSortJUIDescAllowed:a+"carat-1-s",sSortJUIWrapper:"DataTables_sort_wrapper",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead "+n,sScrollFoot:"dataTables_scrollFoot "+n,sHeaderTH:n,sFooterTH:n,sJUIHeader:r+" ui-corner-tl ui-corner-tr",sJUIFooter:r+" ui-corner-bl ui-corner-br"})}();var Vt=ze.ext.pager;e.extend(Vt,{simple:function(e,t){return["previous","next"]},full:function(e,t){return["first","previous","next","last"]},numbers:function(e,t){return[Ee(e,t)]},simple_numbers:function(e,t){return["previous",Ee(e,t),"next"]},full_numbers:function(e,t){return["first","previous",Ee(e,t),"next","last"]},_numbers:Ee,numbers_length:7}),e.extend(!0,ze.ext.renderer,{pageButton:{_:function(t,a,r,o,i,s){var l,u,c,f=t.oClasses,d=t.oLanguage.oPaginate,h=t.oLanguage.oAria.paginate||{},p=0,g=function(n,a){var o,c,b,v,m=function(e){fe(t,e.data.action,!0)};for(o=0,c=a.length;o").appendTo(n);g(S,v)}else{switch(l=null,u="",v){case"ellipsis":n.append('');break;case"first":l=d.sFirst,u=v+(i>0?"":" "+f.sPageButtonDisabled);break;case"previous":l=d.sPrevious,u=v+(i>0?"":" "+f.sPageButtonDisabled);break;case"next":l=d.sNext,u=v+(i",{"class":f.sPageButton+" "+u,"aria-controls":t.sTableId,"aria-label":h[v],"data-dt-idx":p,tabindex:t.iTabIndex,id:0===r&&"string"==typeof v?t.sTableId+"_"+v:null}).html(l).appendTo(n),Ne(b,{action:v},m),p++)}};try{c=e(a).find(n.activeElement).data("dt-idx")}catch(b){}g(e(a).empty(),o),c&&e(a).find("[data-dt-idx="+c+"]").focus()}}}),e.extend(ze.ext.type.detect,[function(e,t){var n=t.oLanguage.sDecimal;return ot(e,n)?"num"+n:null},function(e,t){if(e&&!(e instanceof Date)&&(!Ze.test(e)||!Ke.test(e)))return null;var n=Date.parse(e);return null!==n&&!isNaN(n)||nt(e)?"date":null},function(e,t){var n=t.oLanguage.sDecimal;return ot(e,n,!0)?"num-fmt"+n:null},function(e,t){var n=t.oLanguage.sDecimal;return st(e,n)?"html-num"+n:null},function(e,t){var n=t.oLanguage.sDecimal;return st(e,n,!0)?"html-num-fmt"+n:null},function(e,t){return nt(e)||"string"==typeof e&&e.indexOf("<")!==-1?"html":null}]),e.extend(ze.ext.type.search,{html:function(e){return nt(e)?e:"string"==typeof e?e.replace(Qe," ").replace(Ye,""):""},string:function(e){return nt(e)?e:"string"==typeof e?e.replace(Qe," "):e}});var Xt=function(e,t,n,a){return 0===e||e&&"-"!==e?(t&&(e=rt(e,t)),e.replace&&(n&&(e=e.replace(n,"")),a&&(e=e.replace(a,""))),1*e):-(1/0)};e.extend(Ve.type.order,{"date-pre":function(e){return Date.parse(e)||0},"html-pre":function(e){return nt(e)?"":e.replace?e.replace(/<.*?>/g,"").toLowerCase():e+""},"string-pre":function(e){return nt(e)?"":"string"==typeof e?e.toLowerCase():e.toString?e.toString():""},"string-asc":function(e,t){return et?1:0},"string-desc":function(e,t){return et?-1:0}}),Be(""),e.extend(!0,ze.ext.renderer,{header:{_:function(t,n,a,r){e(t.nTable).on("order.dt.DT",function(e,o,i,s){if(t===o){var l=a.idx;n.removeClass(a.sSortingClass+" "+r.sSortAsc+" "+r.sSortDesc).addClass("asc"==s[l]?r.sSortAsc:"desc"==s[l]?r.sSortDesc:a.sSortingClass)}})},jqueryui:function(t,n,a,r){e("
      ").addClass(r.sSortJUIWrapper).append(n.contents()).append(e("").addClass(r.sSortIcon+" "+a.sSortingClassJUI)).appendTo(n),e(t.nTable).on("order.dt.DT",function(e,o,i,s){if(t===o){var l=a.idx;n.removeClass(r.sSortAsc+" "+r.sSortDesc).addClass("asc"==s[l]?r.sSortAsc:"desc"==s[l]?r.sSortDesc:a.sSortingClass),n.find("span."+r.sSortIcon).removeClass(r.sSortJUIAsc+" "+r.sSortJUIDesc+" "+r.sSortJUI+" "+r.sSortJUIAscAllowed+" "+r.sSortJUIDescAllowed).addClass("asc"==s[l]?r.sSortJUIAsc:"desc"==s[l]?r.sSortJUIDesc:a.sSortingClassJUI)}})}}});var qt=function(e){return"string"==typeof e?e.replace(//g,">").replace(/"/g,"""):e};return ze.render={number:function(e,t,n,a,r){return{display:function(o){if("number"!=typeof o&&"string"!=typeof o)return o;var i=o<0?"-":"",s=parseFloat(o);if(isNaN(s))return qt(o);o=Math.abs(s);var l=parseInt(o,10),u=n?t+(o-l).toFixed(n).substring(2):"";return i+(a||"")+l.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)+u+(r||"")}}},text:function(){return{display:qt}}},e.extend(ze.ext.internal,{_fnExternApiFunc:Je,_fnBuildAjax:J,_fnAjaxUpdate:V,_fnAjaxParameters:X,_fnAjaxUpdateDraw:q,_fnAjaxDataSrc:G,_fnAddColumn:f,_fnColumnOptions:d,_fnAdjustColumnSizing:h,_fnVisibleToColumnIndex:p,_fnColumnIndexToVisible:g,_fnVisbleColumns:b,_fnGetColumns:v,_fnColumnTypes:m,_fnApplyColumnDefs:S,_fnHungarianMap:r,_fnCamelToHungarian:o,_fnLanguageCompat:i,_fnBrowserDetect:u,_fnAddData:D,_fnAddTr:y,_fnNodeToDataIndex:_,_fnNodeToColumnIndex:T,_fnGetCellData:w,_fnSetCellData:C,_fnSplitObjNotation:x,_fnGetObjectDataFn:I,_fnSetObjectDataFn:A,_fnGetDataMaster:F,_fnClearTable:L,_fnDeleteIndex:P,_fnInvalidate:R,_fnGetRowElements:j,_fnCreateTr:H,_fnBuildHead:O,_fnDrawHead:k,_fnDraw:M,_fnReDraw:W,_fnAddOptionsHtml:U,_fnDetectHeader:E,_fnGetUniqueThs:B,_fnFeatureHtmlFilter:z,_fnFilterComplete:$,_fnFilterCustom:Q,_fnFilterColumn:Y,_fnFilter:Z,_fnFilterCreateSearch:K,_fnEscapeRegex:vt,_fnFilterData:ee,_fnFeatureHtmlInfo:ae,_fnUpdateInfo:re,_fnInfoMacros:oe,_fnInitialise:ie,_fnInitComplete:se,_fnLengthChange:le,_fnFeatureHtmlLength:ue,_fnFeatureHtmlPaginate:ce,_fnPageChange:fe,_fnFeatureHtmlProcessing:de,_fnProcessingDisplay:he,_fnFeatureHtmlTable:pe,_fnScrollDraw:ge,_fnApplyToChildren:be,_fnCalculateColumnWidths:ve,_fnThrottle:yt,_fnConvertToWidth:me,_fnGetWidestNode:Se,_fnGetMaxLenString:De,_fnStringToCss:ye,_fnSortFlatten:_e,_fnSort:Te,_fnSortAria:we,_fnSortListener:Ce,_fnSortAttachListener:xe,_fnSortingClasses:Ie,_fnSortData:Ae,_fnSaveState:Fe,_fnLoadState:Le,_fnSettingsFromNode:Pe,_fnLog:Re,_fnMap:je,_fnBindAction:Ne,_fnCallbackReg:Oe,_fnCallbackFire:ke,_fnLengthOverflow:Me,_fnRenderer:We,_fnDataSource:Ue,_fnRowAttributes:N,_fnCalculateEnd:function(){}}),e.fn.dataTable=ze,ze.$=e,e.fn.dataTableSettings=ze.settings,e.fn.dataTableExt=ze.ext,e.fn.DataTable=function(t){return e(this).dataTable(t).api()},e.each(ze,function(t,n){e.fn.DataTable[t]=n}),e.fn.dataTable})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1]); \ No newline at end of file diff --git a/Day61-65/code/project_of_tornado/assets/js/amazeui.min.js b/Day61-65/code/project_of_tornado/assets/js/amazeui.min.js deleted file mode 100644 index f50f9fe..0000000 --- a/Day61-65/code/project_of_tornado/assets/js/amazeui.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! Amaze UI v2.7.2 | by Amaze UI Team | (c) 2016 AllMobilize, Inc. | Licensed under MIT | 2016-08-17T16:17:24+0800 */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?exports.AMUI=e(require("jquery")):t.AMUI=e(t.jQuery)}(this,function(t){return function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){"use strict";var n=i(1),s=i(2);i(3),i(4),i(5),i(6),i(7),i(8),i(9),i(10),i(11),i(14),i(15),i(16),i(17),i(18),i(19),i(20),i(21),i(22),i(24),i(25),i(23),i(27),i(28),i(29),i(30),i(31),i(32),i(33),i(26),i(34),i(35),i(36),i(37),i(38),i(39),i(40),i(41),i(42),i(43),i(44),i(45),i(46),i(47),i(48),i(49),i(50),i(51),i(52),i(53),i(54),t.exports=n.AMUI=s},function(e,i){e.exports=t},function(t,e,i){"use strict";var n=i(1);if("undefined"==typeof n)throw new Error("Amaze UI 2.x requires jQuery :-(\n\u7231\u4e0a\u4e00\u5339\u91ce\u9a6c\uff0c\u53ef\u4f60\u7684\u5bb6\u91cc\u6ca1\u6709\u8349\u539f\u2026");var s=n.AMUI||{},o=n(window),a=window.document,r=n("html");s.VERSION="2.7.2",s.support={},s.support.transition=function(){var t=function(){var t=a.body||a.documentElement,e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return e[i]}();return t&&{end:t}}(),s.support.animation=function(){var t=function(){var t=a.body||a.documentElement,e={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oAnimationEnd oanimationend",animation:"animationend"};for(var i in e)if(void 0!==t.style[i])return e[i]}();return t&&{end:t}}(),s.support.touch="ontouchstart"in window&&navigator.userAgent.toLowerCase().match(/mobile|tablet/)||window.DocumentTouch&&document instanceof window.DocumentTouch||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0||!1,s.support.mutationobserver=window.MutationObserver||window.WebKitMutationObserver||null,s.support.formValidation="function"==typeof document.createElement("form").checkValidity,s.utils={},s.utils.debounce=function(t,e,i){var n;return function(){var s=this,o=arguments,a=function(){n=null,i||t.apply(s,o)},r=i&&!n;clearTimeout(n),n=setTimeout(a,e),r&&t.apply(s,o)}},s.utils.isInView=function(t,e){var i=n(t),s=!(!i.width()&&!i.height())&&"none"!==i.css("display");if(!s)return!1;var a=o.scrollLeft(),r=o.scrollTop(),l=i.offset(),c=l.left,u=l.top;return e=n.extend({topOffset:0,leftOffset:0},e),u+i.height()>=r&&u-e.topOffset<=r+o.height()&&c+i.width()>=a&&c-e.leftOffset<=a+o.width()},s.utils.parseOptions=s.utils.options=function(t){if(n.isPlainObject(t))return t;var e=t?t.indexOf("{"):-1,i={};if(e!=-1)try{i=new Function("","var json = "+t.substr(e)+"; return JSON.parse(JSON.stringify(json));")()}catch(s){}return i},s.utils.generateGUID=function(t){var e=t+"-"||"am-";do e+=Math.random().toString(36).substring(2,7);while(document.getElementById(e));return e},s.utils.getAbsoluteUrl=function(){var t;return function(e){return t||(t=document.createElement("a")),t.href=e,t.href}}(),s.plugin=function(t,e,i){var o=n.fn[t];i=i||{},n.fn[t]=function(o){var a,r=Array.prototype.slice.call(arguments,0),l=r.slice(1),c=this.each(function(){var c=n(this),u="amui."+t,h=i.dataOptions||"data-am-"+t,d=c.data(u),p=n.extend({},s.utils.parseOptions(c.attr(h)),"object"==typeof o&&o);(d||"destroy"!==o)&&(d||c.data(u,d=new e(this,p)),i.methodCall?i.methodCall.call(c,r,d):(i.before&&i.before.call(c,r,d),"string"==typeof o&&(a="function"==typeof d[o]?d[o].apply(d,l):d[o]),i.after&&i.after.call(c,r,d)))});return void 0===a?c:a},n.fn[t].Constructor=e,n.fn[t].noConflict=function(){return n.fn[t]=o,this},s[t]=e},n.fn.emulateTransitionEnd=function(t){var e=!1,i=this;n(this).one(s.support.transition.end,function(){e=!0});var o=function(){e||n(i).trigger(s.support.transition.end),i.transitionEndTimmer=void 0};return this.transitionEndTimmer=setTimeout(o,t),this},n.fn.redraw=function(){return this.each(function(){this.offsetHeight})},n.fn.transitionEnd=function(t){function e(s){t.call(this,s),i&&n.off(i,e)}var i=s.support.transition.end,n=this;return t&&i&&n.on(i,e),this},n.fn.removeClassRegEx=function(){return this.each(function(t){var e=n(this).attr("class");if(!e||!t)return!1;var i=[];e=e.split(" ");for(var s=0,o=e.length;s=window.innerWidth)return 0;var t=n('
      ');n(document.body).append(t);var e=t[0].offsetWidth-t[0].clientWidth;return t.remove(),e},s.utils.imageLoader=function(t,e){function i(){e(t[0])}function n(){if(this.one("load",i),/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var t=this.attr("src"),e=t.match(/\?/)?"&":"?";e+="random="+(new Date).getTime(),this.attr("src",t+e)}}return t.attr("src")?void(t[0].complete||4===t[0].readyState?i():n.call(t)):void i()},s.template=function(t,e){var i=s.template;return i.cache[t]||(i.cache[t]=function(){var e=t,n=/^[\w\-]+$/.test(t)?i.get(t):(e="template(string)",t),s=1,o=("try { "+(i.variable?"var "+i.variable+" = this.stash;":"with (this.stash) { ")+"this.ret += '"+n.replace(/<%/g,"\x11").replace(/%>/g,"\x13").replace(/'(?![^\x11\x13]+?\x13)/g,"\\x27").replace(/^\s*|\s*$/g,"").replace(/\n/g,function(){return"';\nthis.line = "+ ++s+"; this.ret += '\\n"}).replace(/\x11-(.+?)\x13/g,"' + ($1) + '").replace(/\x11=(.+?)\x13/g,"' + this.escapeHTML($1) + '").replace(/\x11(.+?)\x13/g,"'; $1; this.ret += '")+"'; "+(i.variable?"":"}")+"return this.ret;} catch (e) { throw 'TemplateError: ' + e + ' (on "+e+"' + ' line ' + this.line + ')'; } //@ sourceURL="+e+"\n").replace(/this\.ret \+= '';/g,""),a=new Function(o),r={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return(""+t).replace(/[&<>\'\"]/g,function(t){return r[t]})};return function(t){return a.call(i.context={escapeHTML:l,line:1,ret:"",stash:t})}}()),e?i.cache[t](e):i.cache[t]},s.template.cache={},s.template.get=function(t){if(t){var e=document.getElementById(t);return e&&e.innerHTML||""}},s.DOMWatchers=[],s.DOMReady=!1,s.ready=function(t){s.DOMWatchers.push(t),s.DOMReady&&t(document)},s.DOMObserve=function(t,e,i){var o=s.support.mutationobserver;o&&(e=n.isPlainObject(e)?e:{childList:!0,subtree:!0},i="function"==typeof i&&i||function(){},n(t).each(function(){var t=this,a=n(t);if(!a.data("am.observer"))try{var r=new o(s.utils.debounce(function(e,n){i.call(t,e,n),a.trigger("changed.dom.amui")},50));r.observe(t,e),a.data("am.observer",r)}catch(l){}}))},n.fn.DOMObserve=function(t,e){return this.each(function(){s.DOMObserve(this,t,e)})},s.support.touch&&r.addClass("am-touch"),n(document).on("changed.dom.amui",function(t){var e=t.target;n.each(s.DOMWatchers,function(t,i){i(e)})}),n(function(){var t=n(document.body);s.DOMReady=!0,n.each(s.DOMWatchers,function(t,e){e(document)}),s.DOMObserve("[data-am-observe]"),r.removeClass("no-js").addClass("js"),s.support.animation&&r.addClass("cssanimations"),window.navigator.standalone&&r.addClass("am-standalone"),n(".am-topbar-fixed-top").length&&t.addClass("am-with-topbar-fixed-top"),n(".am-topbar-fixed-bottom").length&&t.addClass("am-with-topbar-fixed-bottom");var e=n(".am-layout");e.find('[class*="md-block-grid"]').alterClass("md-block-grid-*"),e.find('[class*="lg-block-grid"]').alterClass("lg-block-grid"),n("[data-am-widget]").each(function(){var t=n(this);0===t.parents(".am-layout").length&&t.addClass("am-no-layout")})}),t.exports=s},function(t,e,i){"use strict";function n(t,e,i){return setTimeout(l(t,i),e)}function s(t,e,i){return!!Array.isArray(t)&&(o(t,i[e],i),!0)}function o(t,e,i){var n;if(t)if(t.forEach)t.forEach(e,i);else if(void 0!==t.length)for(n=0;n\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",s=window.console&&(window.console.warn||window.console.log);return s&&s.call(window.console,n,i),t.apply(this,arguments)}}function r(t,e,i){var n,s=e.prototype;n=t.prototype=Object.create(s),n.constructor=t,n._super=s,i&&ut(n,i)}function l(t,e){return function(){return t.apply(e,arguments)}}function c(t,e){return typeof t==ft?t.apply(e?e[0]||void 0:void 0,e):t}function u(t,e){return void 0===t?e:t}function h(t,e,i){o(f(e),function(e){t.addEventListener(e,i,!1)})}function d(t,e,i){o(f(e),function(e){t.removeEventListener(e,i,!1)})}function p(t,e){for(;t;){if(t==e)return!0;t=t.parentNode}return!1}function m(t,e){return t.indexOf(e)>-1}function f(t){return t.trim().split(/\s+/g)}function v(t,e,i){if(t.indexOf&&!i)return t.indexOf(e);for(var n=0;ni[e]}):n.sort()),n}function w(t,e){for(var i,n,s=e[0].toUpperCase()+e.slice(1),o=0;o1&&!i.firstMultiple?i.firstMultiple=F(e):1===s&&(i.firstMultiple=!1);var o=i.firstInput,a=i.firstMultiple,r=a?a.center:o.center,l=e.center=A(n);e.timeStamp=yt(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=N(r,l),e.distance=P(r,l),k(i,e),e.offsetDirection=M(e.deltaX,e.deltaY);var c=$(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=c.x,e.overallVelocityY=c.y,e.overallVelocity=gt(c.x)>gt(c.y)?c.x:c.y,e.scale=a?O(a.pointers,n):1,e.rotation=a?I(a.pointers,n):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length,D(i,e);var u=t.element;p(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u}function k(t,e){var i=e.center,n=t.offsetDelta||{},s=t.prevDelta||{},o=t.prevInput||{};e.eventType!==Mt&&o.eventType!==Nt||(s=t.prevDelta={x:o.deltaX||0,y:o.deltaY||0},n=t.offsetDelta={x:i.x,y:i.y}),e.deltaX=s.x+(i.x-n.x),e.deltaY=s.y+(i.y-n.y)}function D(t,e){var i,n,s,o,a=t.lastInterval||e,r=e.timeStamp-a.timeStamp;if(e.eventType!=It&&(r>$t||void 0===a.velocity)){var l=e.deltaX-a.deltaX,c=e.deltaY-a.deltaY,u=$(r,l,c);n=u.x,s=u.y,i=gt(u.x)>gt(u.y)?u.x:u.y,o=M(l,c),t.lastInterval=e}else i=a.velocity,n=a.velocityX,s=a.velocityY,o=a.direction;e.velocity=i,e.velocityX=n,e.velocityY=s,e.direction=o}function F(t){for(var e=[],i=0;i=gt(e)?t<0?Lt:_t:e<0?zt:Rt}function P(t,e,i){i||(i=Bt);var n=e[i[0]]-t[i[0]],s=e[i[1]]-t[i[1]];return Math.sqrt(n*n+s*s)}function N(t,e,i){i||(i=Bt);var n=e[i[0]]-t[i[0]],s=e[i[1]]-t[i[1]];return 180*Math.atan2(s,n)/Math.PI}function I(t,e){return N(e[1],e[0],Ut)+N(t[1],t[0],Ut)}function O(t,e){return P(e[0],e[1],Ut)/P(t[0],t[1],Ut)}function L(){this.evEl=Xt,this.evWin=Yt,this.pressed=!1,x.apply(this,arguments)}function _(){this.evEl=Gt,this.evWin=Kt,x.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function z(){this.evTarget=Qt,this.evWin=te,this.started=!1,x.apply(this,arguments)}function R(t,e){var i=g(t.touches),n=g(t.changedTouches);return e&(Nt|It)&&(i=y(i.concat(n),"identifier",!0)),[i,n]}function q(){this.evTarget=ie,this.targetIds={},x.apply(this,arguments)}function W(t,e){var i=g(t.touches),n=this.targetIds;if(e&(Mt|Pt)&&1===i.length)return n[i[0].identifier]=!0,[i,i];var s,o,a=g(t.changedTouches),r=[],l=this.target;if(o=i.filter(function(t){return p(t.target,l)}),e===Mt)for(s=0;s-1&&n.splice(t,1)};setTimeout(s,ne)}}function V(t){for(var e=t.srcEvent.clientX,i=t.srcEvent.clientY,n=0;n-1&&this.requireFail.splice(e,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(t){return!!this.simultaneous[t.id]},emit:function(t){function e(e){i.manager.emit(e,t)}var i=this,n=this.state;n=ge&&e(i.options.event+G(n))},tryEmit:function(t){return this.canEmit()?this.emit(t):void(this.state=be)},canEmit:function(){for(var t=0;te.threshold&&s&e.direction},attrTest:function(t){return Q.prototype.attrTest.call(this,t)&&(this.state&fe||!(this.state&fe)&&this.directionTest(t))},emit:function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=K(t.direction);e&&(t.additionalEvent=this.options.event+e),this._super.emit.call(this,t)}}),r(et,Q,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[ue]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||this.state&fe)},emit:function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}this._super.emit.call(this,t)}}),r(it,Z,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[le]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,s=t.distancee.time;if(this._input=t,!s||!i||t.eventType&(Nt|It)&&!o)this.reset();else if(t.eventType&Mt)this.reset(),this._timer=n(function(){this.state=ye,this.tryEmit()},e.time,this);else if(t.eventType&Nt)return ye;return be},reset:function(){clearTimeout(this._timer)},emit:function(t){this.state===ye&&(t&&t.eventType&Nt?this.manager.emit(this.options.event+"up",t):(this._input.timeStamp=yt(),this.manager.emit(this.options.event,this._input)))}}),r(nt,Q,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[ue]},attrTest:function(t){return this._super.attrTest.call(this,t)&&(Math.abs(t.rotation)>this.options.threshold||this.state&fe)}}),r(st,Q,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:qt|Wt,pointers:1},getTouchAction:function(){return tt.prototype.getTouchAction.call(this)},attrTest:function(t){var e,i=this.options.direction;return i&(qt|Wt)?e=t.overallVelocity:i&qt?e=t.overallVelocityX:i&Wt&&(e=t.overallVelocityY),this._super.attrTest.call(this,t)&&i&t.offsetDirection&&t.distance>this.options.threshold&&t.maxPointers==this.options.pointers&>(e)>this.options.velocity&&t.eventType&Nt},emit:function(t){var e=K(t.offsetDirection);e&&this.manager.emit(this.options.event+e,t),this.manager.emit(this.options.event,t)}}),r(ot,Z,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[ce]},process:function(t){var e=this.options,i=t.pointers.length===e.pointers,s=t.distanceAdd to Home Screen.",android:'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon icon.'},zh_cn:{ios:"\u5982\u8981\u628a\u5e94\u7528\u7a0b\u5f0f\u52a0\u81f3\u4e3b\u5c4f\u5e55,\u8bf7\u70b9\u51fb%icon, \u7136\u540e\u52a0\u81f3\u4e3b\u5c4f\u5e55",android:'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon icon.'},zh_tw:{ios:"\u5982\u8981\u628a\u61c9\u7528\u7a0b\u5f0f\u52a0\u81f3\u4e3b\u5c4f\u5e55, \u8acb\u9ede\u64ca%icon, \u7136\u5f8c\u52a0\u81f3\u4e3b\u5c4f\u5e55.",android:'To add this web app to the home screen open the browser option menu and tap on Add to homescreen. The menu can be accessed by pressing the menu hardware button if your device has one, or by tapping the top right menu icon icon.'}};for(var p in s.intl)s.intl[p.substr(0,2)]=s.intl[p];s.defaults={appID:"org.cubiq.addtohome",fontSize:15,debug:!1,logging:!1,modal:!1,mandatory:!1,autostart:!0,skipFirstVisit:!1,startDelay:1,lifespan:15,displayPace:1440,maxDisplayCount:0,icon:!0,message:"",validLocation:[],onInit:null,onShow:null,onRemove:null,onAdd:null,onPrivate:null,privateModeOverride:!1,detectHomescreen:!1};var m=window.navigator.userAgent,f=window.navigator;o(s,{hasToken:"#ath"==document.location.hash||h.test(document.location.href)||d.test(document.location.search),isRetina:window.devicePixelRatio&&window.devicePixelRatio>1,isIDevice:/iphone|ipod|ipad/i.test(m), -isMobileChrome:m.indexOf("Android")>-1&&/Chrome\/[.0-9]*/.test(m)&&m.indexOf("Version")==-1,isMobileIE:m.indexOf("Windows Phone")>-1,language:f.language&&f.language.toLowerCase().replace("-","_")||""}),s.language=s.language&&s.language in s.intl?s.language:"en_us",s.isMobileSafari=s.isIDevice&&m.indexOf("Safari")>-1&&m.indexOf("CriOS")<0,s.OS=s.isIDevice?"ios":s.isMobileChrome?"android":s.isMobileIE?"windows":"unsupported",s.OSVersion=m.match(/(OS|Android) (\d+[_\.]\d+)/),s.OSVersion=s.OSVersion&&s.OSVersion[2]?+s.OSVersion[2].replace("_","."):0,s.isStandalone="standalone"in window.navigator&&window.navigator.standalone,s.isTablet=s.isMobileSafari&&m.indexOf("iPad")>-1||s.isMobileChrome&&m.indexOf("Mobile")<0,s.isCompatible=s.isMobileSafari&&s.OSVersion>=6||s.isMobileChrome;var v={lastDisplayTime:0,returningVisitor:!1,displayCount:0,optedout:!1,added:!1};s.removeSession=function(t){try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.removeItem(t||s.defaults.appID)}catch(e){}},s.doLog=function(t){this.options.logging&&console.log(t)},s.Class=function(t){if(this.doLog=s.doLog,this.options=o({},s.defaults),o(this.options,t),this.options.debug&&(this.options.logging=!0),l){if(this.options.mandatory=this.options.mandatory&&("standalone"in window.navigator||this.options.debug),this.options.modal=this.options.modal||this.options.mandatory,this.options.mandatory&&(this.options.startDelay=-.5),this.options.detectHomescreen=this.options.detectHomescreen===!0?"hash":this.options.detectHomescreen,this.options.debug&&(s.isCompatible=!0,s.OS="string"==typeof this.options.debug?this.options.debug:"unsupported"==s.OS?"android":s.OS,s.OSVersion="ios"==s.OS?"8":"4"),this.container=document.documentElement,this.session=this.getItem(this.options.appID),this.session=this.session?JSON.parse(this.session):void 0,!s.hasToken||s.isCompatible&&this.session||(s.hasToken=!1,a()),!s.isCompatible)return void this.doLog("Add to homescreen: not displaying callout because device not supported");this.session=this.session||v;try{if(!localStorage)throw new Error("localStorage is not defined");localStorage.setItem(this.options.appID,JSON.stringify(this.session)),s.hasLocalStorage=!0}catch(e){s.hasLocalStorage=!1,this.options.onPrivate&&this.options.onPrivate.call(this)}for(var i=!this.options.validLocation.length,n=this.options.validLocation.length;n--;)if(this.options.validLocation[n].test(document.location.href)){i=!0;break}if(this.getItem("addToHome")&&this.optOut(),this.session.optedout)return void this.doLog("Add to homescreen: not displaying callout because user opted out");if(this.session.added)return void this.doLog("Add to homescreen: not displaying callout because already added to the homescreen");if(!i)return void this.doLog("Add to homescreen: not displaying callout because not a valid location");if(s.isStandalone)return this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&s.hasLocalStorage&&this.options.onAdd.call(this)),void this.doLog("Add to homescreen: not displaying callout because in standalone mode");if(this.options.detectHomescreen){if(s.hasToken)return a(),this.session.added||(this.session.added=!0,this.updateSession(),this.options.onAdd&&s.hasLocalStorage&&this.options.onAdd.call(this)),void this.doLog("Add to homescreen: not displaying callout because URL has token, so we are likely coming from homescreen");"hash"==this.options.detectHomescreen?history.replaceState("",window.document.title,document.location.href+"#ath"):"smartURL"==this.options.detectHomescreen?history.replaceState("",window.document.title,document.location.href.replace(/(\/)?$/,"/ath$1")):history.replaceState("",window.document.title,document.location.href+(document.location.search?"&":"?")+"ath=")}if(!this.session.returningVisitor&&(this.session.returningVisitor=!0,this.updateSession(),this.options.skipFirstVisit))return void this.doLog("Add to homescreen: not displaying callout because skipping first visit");if(!this.options.privateModeOverride&&!s.hasLocalStorage)return void this.doLog("Add to homescreen: not displaying callout because browser is in private mode");this.ready=!0,this.options.onInit&&this.options.onInit.call(this),this.options.autostart&&(this.doLog("Add to homescreen: autostart displaying callout"),this.show())}},s.Class.prototype={events:{load:"_delayedShow",error:"_delayedShow",orientationchange:"resize",resize:"resize",scroll:"resize",click:"remove",touchmove:"_preventDefault",transitionend:"_removeElements",webkitTransitionEnd:"_removeElements",MSTransitionEnd:"_removeElements"},handleEvent:function(t){var e=this.events[t.type];e&&this[e](t)},show:function(t){if(this.options.autostart&&!c)return void setTimeout(this.show.bind(this),50);if(this.shown)return void this.doLog("Add to homescreen: not displaying callout because already shown on screen");var e=Date.now(),i=this.session.lastDisplayTime;if(t!==!0){if(!this.ready)return void this.doLog("Add to homescreen: not displaying callout because not ready");if(e-i<6e4*this.options.displayPace)return void this.doLog("Add to homescreen: not displaying callout because displayed recently");if(this.options.maxDisplayCount&&this.session.displayCount>=this.options.maxDisplayCount)return void this.doLog("Add to homescreen: not displaying callout because displayed too many times already")}this.shown=!0,this.session.lastDisplayTime=e,this.session.displayCount++,this.updateSession(),this.applicationIcon||("ios"==s.OS?this.applicationIcon=document.querySelector('head link[rel^=apple-touch-icon][sizes="152x152"],head link[rel^=apple-touch-icon][sizes="144x144"],head link[rel^=apple-touch-icon][sizes="120x120"],head link[rel^=apple-touch-icon][sizes="114x114"],head link[rel^=apple-touch-icon]'):this.applicationIcon=document.querySelector('head link[rel^="shortcut icon"][sizes="196x196"],head link[rel^=apple-touch-icon]'));var n="";"object"==typeof this.options.message&&s.language in this.options.message?n=this.options.message[s.language][s.OS]:"object"==typeof this.options.message&&s.OS in this.options.message?n=this.options.message[s.OS]:this.options.message in s.intl?n=s.intl[this.options.message][s.OS]:""!==this.options.message?n=this.options.message:s.OS in s.intl[s.language]&&(n=s.intl[s.language][s.OS]),n="

      "+n.replace("%icon",'icon')+"

      ",this.viewport=document.createElement("div"),this.viewport.className="ath-viewport",this.options.modal&&(this.viewport.className+=" ath-modal"),this.options.mandatory&&(this.viewport.className+=" ath-mandatory"),this.viewport.style.position="absolute",this.element=document.createElement("div"),this.element.className="ath-container ath-"+s.OS+" ath-"+s.OS+(s.OSVersion+"").substr(0,1)+" ath-"+(s.isTablet?"tablet":"phone"),this.element.style.cssText="-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0s;-webkit-transition-timing-function:ease-out;transition-property:transform,opacity;transition-duration:0s;transition-timing-function:ease-out;",this.element.style.webkitTransform="translate3d(0,-"+window.innerHeight+"px,0)",this.element.style.transform="translate3d(0,-"+window.innerHeight+"px,0)",this.options.icon&&this.applicationIcon&&(this.element.className+=" ath-icon",this.img=document.createElement("img"),this.img.className="ath-application-icon",this.img.addEventListener("load",this,!1),this.img.addEventListener("error",this,!1),this.img.src=this.applicationIcon.href,this.element.appendChild(this.img)),this.element.innerHTML+=n,this.viewport.style.left="-99999em",this.viewport.appendChild(this.element),this.container.appendChild(this.viewport),this.img?this.doLog("Add to homescreen: not displaying callout because waiting for img to load"):this._delayedShow()},_delayedShow:function(t){setTimeout(this._show.bind(this),1e3*this.options.startDelay+500)},_show:function(){var t=this;this.updateViewport(),window.addEventListener("resize",this,!1),window.addEventListener("scroll",this,!1),window.addEventListener("orientationchange",this,!1),this.options.modal&&document.addEventListener("touchmove",this,!0),this.options.mandatory||setTimeout(function(){t.element.addEventListener("click",t,!0)},1e3),setTimeout(function(){t.element.style.webkitTransitionDuration="1.2s",t.element.style.transitionDuration="1.2s",t.element.style.webkitTransform="translate3d(0,0,0)",t.element.style.transform="translate3d(0,0,0)"},0),this.options.lifespan&&(this.removeTimer=setTimeout(this.remove.bind(this),1e3*this.options.lifespan)),this.options.onShow&&this.options.onShow.call(this)},remove:function(){clearTimeout(this.removeTimer),this.img&&(this.img.removeEventListener("load",this,!1),this.img.removeEventListener("error",this,!1)),window.removeEventListener("resize",this,!1),window.removeEventListener("scroll",this,!1),window.removeEventListener("orientationchange",this,!1),document.removeEventListener("touchmove",this,!0),this.element.removeEventListener("click",this,!0),this.element.addEventListener("transitionend",this,!1),this.element.addEventListener("webkitTransitionEnd",this,!1),this.element.addEventListener("MSTransitionEnd",this,!1),this.element.style.webkitTransitionDuration="0.3s",this.element.style.opacity="0"},_removeElements:function(){this.element.removeEventListener("transitionend",this,!1),this.element.removeEventListener("webkitTransitionEnd",this,!1),this.element.removeEventListener("MSTransitionEnd",this,!1),this.container.removeChild(this.viewport),this.shown=!1,this.options.onRemove&&this.options.onRemove.call(this)},updateViewport:function(){if(this.shown){this.viewport.style.width=window.innerWidth+"px",this.viewport.style.height=window.innerHeight+"px",this.viewport.style.left=window.scrollX+"px",this.viewport.style.top=window.scrollY+"px";var t=document.documentElement.clientWidth;this.orientation=t>document.documentElement.clientHeight?"landscape":"portrait";var e="ios"==s.OS?"portrait"==this.orientation?screen.width:screen.height:screen.width;this.scale=screen.width>t?1:e/window.innerWidth,this.element.style.fontSize=this.options.fontSize/this.scale+"px"}},resize:function(){clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(this.updateViewport.bind(this),100)},updateSession:function(){s.hasLocalStorage!==!1&&localStorage&&localStorage.setItem(this.options.appID,JSON.stringify(this.session))},clearSession:function(){this.session=v,this.updateSession()},getItem:function(t){try{if(!localStorage)throw new Error("localStorage is not defined");return localStorage.getItem(t)}catch(e){s.hasLocalStorage=!1}},optOut:function(){this.session.optedout=!0,this.updateSession()},optIn:function(){this.session.optedout=!1,this.updateSession()},clearDisplayCount:function(){this.session.displayCount=0,this.updateSession()},_preventDefault:function(t){t.preventDefault(),t.stopPropagation()}},s.VERSION="3.2.2",t.exports=r.addToHomescreen=s},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){var i=this;this.options=n.extend({},o.DEFAULTS,e),this.$element=n(t),this.$element.addClass("am-fade am-in").on("click.alert.amui",".am-close",function(){i.close()})};o.DEFAULTS={removeElement:!0},o.prototype.close=function(){function t(){e.trigger("closed.alert.amui").remove()}var e=this.$element;e.trigger("close.alert.amui").removeClass("am-in"),s.support.transition&&e.hasClass("am-fade")?e.one(s.support.transition.end,t).emulateTransitionEnd(200):t()},s.plugin("alert",o),n(document).on("click.alert.amui.data-api","[data-am-alert]",function(t){var e=n(t.target);e.is(".am-close")&&n(this).alert("close")}),t.exports=o},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){this.$element=n(t),this.options=n.extend({},o.DEFAULTS,e),this.isLoading=!1,this.hasSpinner=!1};o.DEFAULTS={loadingText:"loading...",disabledClassName:"am-disabled",activeClassName:"am-active",spinner:void 0},o.prototype.setState=function(t,e){var i=this.$element,o="disabled",a=i.data(),r=this.options,l=i.is("input")?"val":"html",c="am-btn-"+t+" "+r.disabledClassName;t+="Text",r.resetText||(r.resetText=i[l]()),s.support.animation&&r.spinner&&"html"===l&&!this.hasSpinner&&(r.loadingText=''+r.loadingText,this.hasSpinner=!0),e=e||(void 0===a[t]?r[t]:a[t]),i[l](e),setTimeout(n.proxy(function(){"loadingText"===t?(i.addClass(c).attr(o,o),this.isLoading=!0):this.isLoading&&(i.removeClass(c).removeAttr(o),this.isLoading=!1)},this),0)},o.prototype.toggle=function(){var t=!0,e=this.$element,i=this.$element.parent('[class*="am-btn-group"]'),n=o.DEFAULTS.activeClassName;if(i.length){var s=this.$element.find("input");"radio"==s.prop("type")&&(s.prop("checked")&&e.hasClass(n)?t=!1:i.find("."+n).removeClass(n)),t&&s.prop("checked",!e.hasClass(n)).trigger("change")}t&&(e.toggleClass(n),e.hasClass(n)||e.blur())},s.plugin("button",o,{dataOptions:"data-am-loading",methodCall:function(t,e){"toggle"===t[0]?e.toggle():"string"==typeof t[0]&&e.setState.apply(e,t)}}),n(document).on("click.button.amui.data-api","[data-am-button]",function(t){t.preventDefault();var e=n(t.target);e.hasClass("am-btn")||(e=e.closest(".am-btn")),e.button("toggle")}),s.ready(function(t){n("[data-am-loading]",t).button(),n("[data-am-button]",t).find("input:checked").each(function(){n(this).parent("label").addClass(o.DEFAULTS.activeClassName)})}),t.exports=s.button=o},function(t,e,i){"use strict";function n(t){return this.each(function(){var e=s(this),i=e.data("amui.collapse"),n=s.extend({},a.DEFAULTS,o.utils.options(e.attr("data-am-collapse")),"object"==typeof t&&t);!i&&n.toggle&&"open"===t&&(t=!t),i||e.data("amui.collapse",i=new a(this,n)),"string"==typeof t&&i[t]()})}var s=i(1),o=i(2),a=function(t,e){this.$element=s(t),this.options=s.extend({},a.DEFAULTS,e),this.transitioning=null,this.options.parent&&(this.$parent=s(this.options.parent)),this.options.toggle&&this.toggle()};a.DEFAULTS={toggle:!0},a.prototype.open=function(){if(!this.transitioning&&!this.$element.hasClass("am-in")){var t=s.Event("open.collapse.amui");if(this.$element.trigger(t),!t.isDefaultPrevented()){var e=this.$parent&&this.$parent.find("> .am-panel > .am-in");if(e&&e.length){var i=e.data("amui.collapse");if(i&&i.transitioning)return;n.call(e,"close"),i||e.data("amui.collapse",null)}this.$element.removeClass("am-collapse").addClass("am-collapsing").height(0),this.transitioning=1;var a=function(){this.$element.removeClass("am-collapsing").addClass("am-collapse am-in").height("").trigger("opened.collapse.amui"),this.transitioning=0};if(!o.support.transition)return a.call(this);var r=this.$element[0].scrollHeight;this.$element.one(o.support.transition.end,s.proxy(a,this)).emulateTransitionEnd(300).css({height:r})}}},a.prototype.close=function(){if(!this.transitioning&&this.$element.hasClass("am-in")){var t=s.Event("close.collapse.amui");if(this.$element.trigger(t),!t.isDefaultPrevented()){this.$element.height(this.$element.height()).redraw(),this.$element.addClass("am-collapsing").removeClass("am-collapse am-in"),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.trigger("closed.collapse.amui").removeClass("am-collapsing").addClass("am-collapse")};return o.support.transition?void this.$element.height(0).one(o.support.transition.end,s.proxy(e,this)).emulateTransitionEnd(300):e.call(this)}}},a.prototype.toggle=function(){this[this.$element.hasClass("am-in")?"close":"open"]()},s.fn.collapse=n,s(document).on("click.collapse.amui.data-api","[data-am-collapse]",function(t){var e,i=s(this),a=o.utils.options(i.attr("data-am-collapse")),r=a.target||t.preventDefault()||(e=i.attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,""),l=s(r),c=l.data("amui.collapse"),u=c?"toggle":a,h=a.parent,d=h&&s(h);c&&c.transitioning||(d&&d.find("[data-am-collapse]").not(i).addClass("am-collapsed"),i[l.hasClass("am-in")?"addClass":"removeClass"]("am-collapsed")),n.call(l,u)}),t.exports=o.collapse=a},function(t,e,i){"use strict";var n=i(1),s=i(2),o=n(document),a=function(t,e){if(this.$element=n(t),this.options=n.extend({},a.DEFAULTS,e),this.format=r.parseFormat(this.options.format),this.$element.data("date",this.options.date),this.language=this.getLocale(this.options.locale),this.theme=this.options.theme,this.$picker=n(r.template).appendTo("body").on({click:n.proxy(this.click,this)}),this.isInput=this.$element.is("input"),this.component=!!this.$element.is(".am-datepicker-date")&&this.$element.find(".am-datepicker-add-on"),this.isInput?this.$element.on({"click.datepicker.amui":n.proxy(this.open,this),"keyup.datepicker.amui":n.proxy(this.update,this)}):this.component?this.component.on("click.datepicker.amui",n.proxy(this.open,this)):this.$element.on("click.datepicker.amui",n.proxy(this.open,this)),this.minViewMode=this.options.minViewMode,"string"==typeof this.minViewMode)switch(this.minViewMode){case"months":this.minViewMode=1;break;case"years":this.minViewMode=2;break;default:this.minViewMode=0}if(this.viewMode=this.options.viewMode,"string"==typeof this.viewMode)switch(this.viewMode){case"months":this.viewMode=1;break;case"years":this.viewMode=2;break;default:this.viewMode=0}this.startViewMode=this.viewMode,this.weekStart=(this.options.weekStart||a.locales[this.language].weekStart||0)%7,this.weekEnd=(this.weekStart+6)%7,this.onRender=this.options.onRender,this.setTheme(),this.fillDow(),this.fillMonths(),this.update(),this.showMode()};a.DEFAULTS={locale:"zh_CN",format:"yyyy-mm-dd",weekStart:void 0,viewMode:0,minViewMode:0,date:"",theme:"",autoClose:1,onRender:function(t){return""}},a.prototype.open=function(t){this.$picker.show(),this.height=this.component?this.component.outerHeight():this.$element.outerHeight(),this.place(),n(window).on("resize.datepicker.amui",n.proxy(this.place,this)),t&&(t.stopPropagation(),t.preventDefault());var e=this;o.on("mousedown.datapicker.amui touchstart.datepicker.amui",function(t){0===n(t.target).closest(".am-datepicker").length&&e.close()}),this.$element.trigger({type:"open.datepicker.amui",date:this.date})},a.prototype.close=function(){this.$picker.hide(),n(window).off("resize.datepicker.amui",this.place),this.viewMode=this.startViewMode,this.showMode(),this.isInput||n(document).off("mousedown.datapicker.amui touchstart.datepicker.amui",this.close),this.$element.trigger({type:"close.datepicker.amui",date:this.date})},a.prototype.set=function(){var t,e=r.formatDate(this.date,this.format);this.isInput?t=this.$element.attr("value",e):(this.component&&(t=this.$element.find("input").attr("value",e)),this.$element.data("date",e)),t&&t.trigger("change")},a.prototype.setValue=function(t){"string"==typeof t?this.date=r.parseDate(t,this.format):this.date=new Date(t),this.set(),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},a.prototype.place=function(){var t=this.component?this.component.offset():this.$element.offset(),e=this.component?this.component.width():this.$element.width(),i=t.top+this.height,n=t.left,s=o.width()-t.left-e,a=this.isOutView();if(this.$picker.removeClass("am-datepicker-right"),this.$picker.removeClass("am-datepicker-up"),o.width()>640){if(a.outRight)return this.$picker.addClass("am-datepicker-right"),void this.$picker.css({top:i,left:"auto",right:s});a.outBottom&&(this.$picker.addClass("am-datepicker-up"),i=t.top-this.$picker.outerHeight(!0))}else n=0;this.$picker.css({top:i,left:n})},a.prototype.update=function(t){this.date=r.parseDate("string"==typeof t?t:this.isInput?this.$element.prop("value"):this.$element.data("date"),this.format),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},a.prototype.fillDow=function(){for(var t=this.weekStart,e="";t'+a.locales[this.language].daysMin[t++%7]+"";e+="",this.$picker.find(".am-datepicker-days thead").append(e)},a.prototype.fillMonths=function(){for(var t="",e=0;e<12;)t+=''+a.locales[this.language].monthsShort[e++]+"";this.$picker.find(".am-datepicker-months td").append(t)},a.prototype.fill=function(){var t=new Date(this.viewDate),e=t.getFullYear(),i=t.getMonth(),n=this.date.valueOf(),s=new Date(e,i-1,28,0,0,0,0),o=r.getDaysInMonth(s.getFullYear(),s.getMonth()),l=this.$picker.find(".am-datepicker-days .am-datepicker-select");"zh_CN"===this.language?l.text(e+a.locales[this.language].year[0]+" "+a.locales[this.language].months[i]):l.text(a.locales[this.language].months[i]+" "+e),s.setDate(o),s.setDate(o-(s.getDay()-this.weekStart+7)%7);var c=new Date(s);c.setDate(c.getDate()+42),c=c.valueOf();for(var u,h,d,p=[];s.valueOf()"),u=this.onRender(s,0),h=s.getFullYear(),d=s.getMonth(),di&&h===e||h>e)&&(u+=" am-datepicker-new"),s.valueOf()===n&&(u+=" am-active"),p.push(''+s.getDate()+""),s.getDay()===this.weekEnd&&p.push(""),s.setDate(s.getDate()+1);this.$picker.find(".am-datepicker-days tbody").empty().append(p.join(""));var m=this.date.getFullYear(),f=this.$picker.find(".am-datepicker-months").find(".am-datepicker-select").text(e);f=f.end().find("span").removeClass("am-active").removeClass("am-disabled");for(var v=0;v<12;)this.onRender(t.setFullYear(e,v),1)&&f.eq(v).addClass("am-disabled"),v++;m===e&&f.eq(this.date.getMonth()).removeClass("am-disabled").addClass("am-active"),p="",e=10*parseInt(e/10,10);var g,y=this.$picker.find(".am-datepicker-years").find(".am-datepicker-select").text(e+"-"+(e+9)).end().find("td"),w=new Date(this.viewDate);e-=1;for(var b=-1;b<11;b++)g=this.onRender(w.setFullYear(e),2),p+=''+e+"",e+=1;y.html(p)},a.prototype.click=function(t){t.stopPropagation(),t.preventDefault();var e,i,s=this.$picker.find(".am-datepicker-days").find(".am-active"),o=this.$picker.find(".am-datepicker-months"),a=o.find(".am-active").index(),l=n(t.target).closest("span, td, th");if(1===l.length)switch(l[0].nodeName.toLowerCase()){case"th":switch(l[0].className){case"am-datepicker-switch":this.showMode(1);break;case"am-datepicker-prev":case"am-datepicker-next":this.viewDate["set"+r.modes[this.viewMode].navFnc].call(this.viewDate,this.viewDate["get"+r.modes[this.viewMode].navFnc].call(this.viewDate)+r.modes[this.viewMode].navStep*("am-datepicker-prev"===l[0].className?-1:1)),this.fill(),this.set()}break;case"span":if(l.is(".am-disabled"))return;l.is(".am-datepicker-month")?(e=l.parent().find("span").index(l),l.is(".am-active")?this.viewDate.setMonth(e,s.text()):this.viewDate.setMonth(e)):(i=parseInt(l.text(),10)||0,l.is(".am-active")?this.viewDate.setFullYear(i,a,s.text()):this.viewDate.setFullYear(i)),0!==this.viewMode&&(this.date=new Date(this.viewDate),this.$element.trigger({type:"changeDate.datepicker.amui",date:this.date,viewMode:r.modes[this.viewMode].clsName})),this.showMode(-1),this.fill(),this.set();break;case"td":if(l.is(".am-datepicker-day")&&!l.is(".am-disabled")){var c=parseInt(l.text(),10)||1;e=this.viewDate.getMonth(),l.is(".am-datepicker-old")?e-=1:l.is(".am-datepicker-new")&&(e+=1),i=this.viewDate.getFullYear(),this.date=new Date(i,e,c,0,0,0,0),this.viewDate=new Date(i,e,Math.min(28,c),0,0,0,0),this.fill(),this.set(),this.$element.trigger({type:"changeDate.datepicker.amui",date:this.date,viewMode:r.modes[this.viewMode].clsName}),this.options.autoClose&&this.close()}}},a.prototype.mousedown=function(t){t.stopPropagation(),t.preventDefault()},a.prototype.showMode=function(t){t&&(this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+t))),this.$picker.find(">div").hide().filter(".am-datepicker-"+r.modes[this.viewMode].clsName).show()},a.prototype.isOutView=function(){var t=this.component?this.component.offset():this.$element.offset(),e={outRight:!1,outBottom:!1},i=this.$picker,n=t.left+i.outerWidth(!0),s=t.top+i.outerHeight(!0)+this.$element.innerHeight();return n>o.width()&&(e.outRight=!0),s>o.height()&&(e.outBottom=!0),e},a.prototype.getLocale=function(t){return t||(t=navigator.language&&navigator.language.split("-"),t[1]=t[1].toUpperCase(),t=t.join("_")),a.locales[t]||(t="en_US"),t},a.prototype.setTheme=function(){this.theme&&this.$picker.addClass("am-datepicker-"+this.theme)},a.locales={en_US:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekStart:0},zh_CN:{days:["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"],daysShort:["\u5468\u65e5","\u5468\u4e00","\u5468\u4e8c","\u5468\u4e09","\u5468\u56db","\u5468\u4e94","\u5468\u516d"],daysMin:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],months:["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],monthsShort:["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],weekStart:1,year:["\u5e74"]}};var r={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],isLeapYear:function(t){return t%4===0&&t%100!==0||t%400===0},getDaysInMonth:function(t,e){return[31,r.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31][e]},parseFormat:function(t){var e=t.match(/[.\/\-\s].*?/),i=t.split(/\W+/);if(!e||!i||0===i.length)throw new Error("Invalid date format.");return{separator:e,parts:i}},parseDate:function(t,e){var i,n=t.split(e.separator);if(t=new Date,t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),n.length===e.parts.length){for(var s=t.getFullYear(),o=t.getDate(),a=t.getMonth(),r=0,l=e.parts.length;r
      ',contTemplate:''};r.template='
      '+r.headTemplate+'
      '+r.headTemplate+r.contTemplate+'
      '+r.headTemplate+r.contTemplate+"
      ",s.plugin("datepicker",a),s.ready(function(t){n("[data-am-datepicker]").datepicker()}),t.exports=s.datepicker=a},function(t,e,i){"use strict";var n=i(1),s=i(2),o=n(document),a=s.support.transition,r=function(){this.id=s.utils.generateGUID("am-dimmer"),this.$element=n(r.DEFAULTS.tpl,{id:this.id}),this.inited=!1,this.scrollbarWidth=0,this.$used=n([])};r.DEFAULTS={tpl:'
      '},r.prototype.init=function(){return this.inited||(n(document.body).append(this.$element),this.inited=!0,o.trigger("init.dimmer.amui"),this.$element.on("touchmove.dimmer.amui",function(t){t.preventDefault()})),this},r.prototype.open=function(t){this.inited||this.init();var e=this.$element;return t&&(this.$used=this.$used.add(n(t))),this.checkScrollbar().setScrollbar(),e.show().trigger("open.dimmer.amui"),a&&e.off(a.end),setTimeout(function(){e.addClass("am-active")},0),this},r.prototype.close=function(t,e){function i(){s.hide(),this.resetScrollbar()}if(this.$used=this.$used.not(n(t)),!e&&this.$used.length)return this;var s=this.$element;return s.removeClass("am-active").trigger("close.dimmer.amui"),i.call(this),this},r.prototype.checkScrollbar=function(){return this.scrollbarWidth=s.utils.measureScrollbar(),this},r.prototype.setScrollbar=function(){var t=n(document.body),e=parseInt(t.css("padding-right")||0,10);return this.scrollbarWidth&&t.css("padding-right",e+this.scrollbarWidth),t.addClass("am-dimmer-active"),this},r.prototype.resetScrollbar=function(){return n(document.body).css("padding-right","").removeClass("am-dimmer-active"),this},t.exports=s.dimmer=new r},function(t,e,i){"use strict";var n=i(1),s=i(2),o=s.support.animation,a=function(t,e){this.options=n.extend({},a.DEFAULTS,e),e=this.options,this.$element=n(t),this.$toggle=this.$element.find(e.selector.toggle),this.$dropdown=this.$element.find(e.selector.dropdown),this.$boundary=e.boundary===window?n(window):this.$element.closest(e.boundary),this.$justify=e.justify&&n(e.justify).length&&n(e.justify)||void 0,!this.$boundary.length&&(this.$boundary=n(window)),this.active=!!this.$element.hasClass("am-active"),this.animating=null,this.events()};a.DEFAULTS={animation:"am-animation-slide-top-fixed",boundary:window,justify:void 0,selector:{dropdown:".am-dropdown-content",toggle:".am-dropdown-toggle"},trigger:"click"},a.prototype.toggle=function(){this.clear(),this.animating||this[this.active?"close":"open"]()},a.prototype.open=function(t){var e=this.$toggle,i=this.$element,s=this.$dropdown;if(!e.is(".am-disabled, :disabled")&&!this.active){i.trigger("open.dropdown.amui").addClass("am-active"),e.trigger("focus"),this.checkDimensions(t);var a=n.proxy(function(){i.trigger("opened.dropdown.amui"),this.active=!0,this.animating=0},this);o?(this.animating=1,s.addClass(this.options.animation).on(o.end+".open.dropdown.amui",n.proxy(function(){a(),s.removeClass(this.options.animation)},this))):a()}},a.prototype.close=function(){if(this.active){var t="am-dropdown-animation",e=this.$element,i=this.$dropdown;e.trigger("close.dropdown.amui");var s=n.proxy(function(){e.removeClass("am-active").trigger("closed.dropdown.amui"),this.active=!1,this.animating=0,this.$toggle.blur()},this);o?(i.removeClass(this.options.animation),i.addClass(t),this.animating=1,i.one(o.end+".close.dropdown.amui",function(){i.removeClass(t),s()})):s()}},a.prototype.enable=function(){this.$toggle.prop("disabled",!1)},a.prototype.disable=function(){this.$toggle.prop("disabled",!0)},a.prototype.checkDimensions=function(t){if(this.$dropdown.length){var e=this.$dropdown;t&&t.offset&&e.offset(t.offset);var i=e.offset(),s=e.outerWidth(),o=this.$boundary.width(),a=n.isWindow(this.boundary)&&this.$boundary.offset()?this.$boundary.offset().left:0;this.$justify&&e.css({"min-width":this.$justify.css("width")}),s+(i.left-a)>o&&this.$element.addClass("am-dropdown-flip")}},a.prototype.clear=function(){n("[data-am-dropdown]").not(this.$element).each(function(){var t=n(this).data("amui.dropdown");t&&t.close()})},a.prototype.events=function(){var t="dropdown.amui",e=this.$toggle;e.on("click."+t,n.proxy(function(t){t.preventDefault(),this.toggle()},this)),n(document).on("keydown.dropdown.amui",n.proxy(function(t){27===t.keyCode&&this.active&&this.close()},this)).on("click.outer.dropdown.amui",n.proxy(function(t){!this.active||this.$element[0]!==t.target&&this.$element.find(t.target).length||this.close()},this))},s.plugin("dropdown",a),s.ready(function(t){n("[data-am-dropdown]",t).dropdown()}),n(document).on("click.dropdown.amui.data-api",".am-dropdown form",function(t){ -t.stopPropagation()}),t.exports=s.dropdown=a},function(t,e,i){(function(e){var n=i(1),s=i(2),o=!0;n.flexslider=function(t,i){var s=n(t);s.vars=n.extend({},n.flexslider.defaults,i);var a,r=s.vars.namespace,l=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,c=("ontouchstart"in window||l||window.DocumentTouch&&document instanceof DocumentTouch)&&s.vars.touch,u="click touchend MSPointerUp keyup",h="",d="vertical"===s.vars.direction,p=s.vars.reverse,m=s.vars.itemWidth>0,f="fade"===s.vars.animation,v=""!==s.vars.asNavFor,g={};n.data(t,"flexslider",s),g={init:function(){s.animating=!1,s.currentSlide=parseInt(s.vars.startAt?s.vars.startAt:0,10),isNaN(s.currentSlide)&&(s.currentSlide=0),s.animatingTo=s.currentSlide,s.atEnd=0===s.currentSlide||s.currentSlide===s.last,s.containerSelector=s.vars.selector.substr(0,s.vars.selector.search(" ")),s.slides=n(s.vars.selector,s),s.container=n(s.containerSelector,s),s.count=s.slides.length,s.syncExists=n(s.vars.sync).length>0,"slide"===s.vars.animation&&(s.vars.animation="swing"),s.prop=d?"top":"marginLeft",s.args={},s.manualPause=!1,s.stopped=!1,s.started=!1,s.startTimeout=null,s.transitions=!s.vars.video&&!f&&s.vars.useCSS&&function(){var t=document.createElement("div"),e=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return s.pfx=e[i].replace("Perspective","").toLowerCase(),s.prop="-"+s.pfx+"-transform",!0;return!1}(),s.ensureAnimationEnd="",""!==s.vars.controlsContainer&&(s.controlsContainer=n(s.vars.controlsContainer).length>0&&n(s.vars.controlsContainer)),""!==s.vars.manualControls&&(s.manualControls=n(s.vars.manualControls).length>0&&n(s.vars.manualControls)),""!==s.vars.customDirectionNav&&(s.customDirectionNav=2===n(s.vars.customDirectionNav).length&&n(s.vars.customDirectionNav)),s.vars.randomize&&(s.slides.sort(function(){return Math.round(Math.random())-.5}),s.container.empty().append(s.slides)),s.doMath(),s.setup("init"),s.vars.controlNav&&g.controlNav.setup(),s.vars.directionNav&&g.directionNav.setup(),s.vars.keyboard&&(1===n(s.containerSelector).length||s.vars.multipleKeyboard)&&n(document).bind("keyup",function(t){var e=t.keyCode;if(!s.animating&&(39===e||37===e)){var i=39===e?s.getTarget("next"):37===e&&s.getTarget("prev");s.flexAnimate(i,s.vars.pauseOnAction)}}),s.vars.mousewheel&&s.bind("mousewheel",function(t,e,i,n){t.preventDefault();var o=e<0?s.getTarget("next"):s.getTarget("prev");s.flexAnimate(o,s.vars.pauseOnAction)}),s.vars.pausePlay&&g.pausePlay.setup(),s.vars.slideshow&&s.vars.pauseInvisible&&g.pauseInvisible.init(),s.vars.slideshow&&(s.vars.pauseOnHover&&s.hover(function(){s.manualPlay||s.manualPause||s.pause()},function(){s.manualPause||s.manualPlay||s.stopped||s.play()}),s.vars.pauseInvisible&&g.pauseInvisible.isHidden()||(s.vars.initDelay>0?s.startTimeout=setTimeout(s.play,s.vars.initDelay):s.play())),v&&g.asNav.setup(),c&&s.vars.touch&&g.touch(),(!f||f&&s.vars.smoothHeight)&&n(window).bind("resize orientationchange focus",g.resize),s.find("img").attr("draggable","false"),setTimeout(function(){s.vars.start(s)},200)},asNav:{setup:function(){s.asNav=!0,s.animatingTo=Math.floor(s.currentSlide/s.move),s.currentItem=s.currentSlide,s.slides.removeClass(r+"active-slide").eq(s.currentItem).addClass(r+"active-slide"),l?(t._slider=s,s.slides.each(function(){var t=this;t._gesture=new MSGesture,t._gesture.target=t,t.addEventListener("MSPointerDown",function(t){t.preventDefault(),t.currentTarget._gesture&&t.currentTarget._gesture.addPointer(t.pointerId)},!1),t.addEventListener("MSGestureTap",function(t){t.preventDefault();var e=n(this),i=e.index();n(s.vars.asNavFor).data("flexslider").animating||e.hasClass("active")||(s.direction=s.currentItem'),s.pagingCount>1)for(var a=0;a":''+o+"","thumbnails"===s.vars.controlNav&&!0===s.vars.thumbCaptions){var c=e.attr("data-thumbcaption");""!==c&&void 0!==c&&(t+=''+c+"")}s.controlNavScaffold.append("
    • "+t+"
    • "),o++}s.controlsContainer?n(s.controlsContainer).append(s.controlNavScaffold):s.append(s.controlNavScaffold),g.controlNav.set(),g.controlNav.active(),s.controlNavScaffold.delegate("a, img",u,function(t){if(t.preventDefault(),""===h||h===t.type){var e=n(this),i=s.controlNav.index(e);e.hasClass(r+"active")||(s.direction=i>s.currentSlide?"next":"prev",s.flexAnimate(i,s.vars.pauseOnAction))}""===h&&(h=t.type),g.setToClearWatchedEvent()})},setupManual:function(){s.controlNav=s.manualControls,g.controlNav.active(),s.controlNav.bind(u,function(t){if(t.preventDefault(),""===h||h===t.type){var e=n(this),i=s.controlNav.index(e);e.hasClass(r+"active")||(i>s.currentSlide?s.direction="next":s.direction="prev",s.flexAnimate(i,s.vars.pauseOnAction))}""===h&&(h=t.type),g.setToClearWatchedEvent()})},set:function(){var t="thumbnails"===s.vars.controlNav?"img":"a";s.controlNav=n("."+r+"control-nav li "+t,s.controlsContainer?s.controlsContainer:s)},active:function(){s.controlNav.removeClass(r+"active").eq(s.animatingTo).addClass(r+"active")},update:function(t,e){s.pagingCount>1&&"add"===t?s.controlNavScaffold.append(n('
    • '+s.count+"
    • ")):1===s.pagingCount?s.controlNavScaffold.find("li").remove():s.controlNav.eq(e).closest("li").remove(),g.controlNav.set(),s.pagingCount>1&&s.pagingCount!==s.controlNav.length?s.update(e,t):g.controlNav.active()}},directionNav:{setup:function(){var t=n('");s.customDirectionNav?s.directionNav=s.customDirectionNav:s.controlsContainer?(n(s.controlsContainer).append(t),s.directionNav=n("."+r+"direction-nav li a",s.controlsContainer)):(s.append(t),s.directionNav=n("."+r+"direction-nav li a",s)),g.directionNav.update(),s.directionNav.bind(u,function(t){t.preventDefault();var e;""!==h&&h!==t.type||(e=n(this).hasClass(r+"next")?s.getTarget("next"):s.getTarget("prev"),s.flexAnimate(e,s.vars.pauseOnAction)),""===h&&(h=t.type),g.setToClearWatchedEvent()})},update:function(){var t=r+"disabled";1===s.pagingCount?s.directionNav.addClass(t).attr("tabindex","-1"):s.vars.animationLoop?s.directionNav.removeClass(t).removeAttr("tabindex"):0===s.animatingTo?s.directionNav.removeClass(t).filter("."+r+"prev").addClass(t).attr("tabindex","-1"):s.animatingTo===s.last?s.directionNav.removeClass(t).filter("."+r+"next").addClass(t).attr("tabindex","-1"):s.directionNav.removeClass(t).removeAttr("tabindex")}},pausePlay:{setup:function(){var t=n('
      ');s.controlsContainer?(s.controlsContainer.append(t),s.pausePlay=n("."+r+"pauseplay a",s.controlsContainer)):(s.append(t),s.pausePlay=n("."+r+"pauseplay a",s)),g.pausePlay.update(s.vars.slideshow?r+"pause":r+"play"),s.pausePlay.bind(u,function(t){t.preventDefault(),""!==h&&h!==t.type||(n(this).hasClass(r+"pause")?(s.manualPause=!0,s.manualPlay=!1,s.pause()):(s.manualPause=!1,s.manualPlay=!0,s.play())),""===h&&(h=t.type),g.setToClearWatchedEvent()})},update:function(t){"play"===t?s.pausePlay.removeClass(r+"pause").addClass(r+"play").html(s.vars.playText):s.pausePlay.removeClass(r+"play").addClass(r+"pause").html(s.vars.pauseText)}},touch:function(){function i(e){e.stopPropagation(),s.animating?e.preventDefault():(s.pause(),t._gesture.addPointer(e.pointerId),C=0,u=d?s.h:s.w,v=Number(new Date),c=m&&p&&s.animatingTo===s.last?0:m&&p?s.limit-(s.itemW+s.vars.itemMargin)*s.move*s.animatingTo:m&&s.currentSlide===s.last?s.limit:m?(s.itemW+s.vars.itemMargin)*s.move*s.currentSlide:p?(s.last-s.currentSlide+s.cloneOffset)*u:(s.currentSlide+s.cloneOffset)*u)}function n(i){i.stopPropagation();var n=i.target._slider;if(n){var s=-i.translationX,o=-i.translationY;return C+=d?o:s,h=C,b=d?Math.abs(C)500)&&(i.preventDefault(),!f&&n.transitions&&(n.vars.animationLoop||(h=C/(0===n.currentSlide&&C<0||n.currentSlide===n.last&&C>0?Math.abs(C)/u+2:1)),n.setProps(c+h,"setTouch"))))}}function o(t){t.stopPropagation();var e=t.target._slider;if(e){if(e.animatingTo===e.currentSlide&&!b&&null!==h){var i=p?-h:h,n=i>0?e.getTarget("next"):e.getTarget("prev");e.canAdvance(n)&&(Number(new Date)-v<550&&Math.abs(i)>50||Math.abs(i)>u/2)?e.flexAnimate(n,e.vars.pauseOnAction):f||e.flexAnimate(e.currentSlide,e.vars.pauseOnAction,!0)}a=null,r=null,h=null,c=null,C=0}}var a,r,c,u,h,v,g,y,w,b=!1,T=0,x=0,C=0;l?(t.style.msTouchAction="none",t._gesture=new MSGesture,t._gesture.target=t,t.addEventListener("MSPointerDown",i,!1),t._slider=s,t.addEventListener("MSGestureChange",n,!1),t.addEventListener("MSGestureEnd",o,!1)):(g=function(e){s.animating?e.preventDefault():(window.navigator.msPointerEnabled||1===e.touches.length)&&(s.pause(),u=d?s.h:s.w,v=Number(new Date),T=e.touches[0].pageX,x=e.touches[0].pageY,c=m&&p&&s.animatingTo===s.last?0:m&&p?s.limit-(s.itemW+s.vars.itemMargin)*s.move*s.animatingTo:m&&s.currentSlide===s.last?s.limit:m?(s.itemW+s.vars.itemMargin)*s.move*s.currentSlide:p?(s.last-s.currentSlide+s.cloneOffset)*u:(s.currentSlide+s.cloneOffset)*u,a=d?x:T,r=d?T:x,t.addEventListener("touchmove",y,!1),t.addEventListener("touchend",w,!1))},y=function(t){T=t.touches[0].pageX,x=t.touches[0].pageY,h=d?a-x:a-T,b=d?Math.abs(h)e)&&(t.preventDefault(),!f&&s.transitions&&(s.vars.animationLoop||(h/=0===s.currentSlide&&h<0||s.currentSlide===s.last&&h>0?Math.abs(h)/u+2:1),s.setProps(c+h,"setTouch")))},w=function(e){if(t.removeEventListener("touchmove",y,!1),s.animatingTo===s.currentSlide&&!b&&null!==h){var i=p?-h:h,n=i>0?s.getTarget("next"):s.getTarget("prev");s.canAdvance(n)&&(Number(new Date)-v<550&&Math.abs(i)>50||Math.abs(i)>u/2)?s.flexAnimate(n,s.vars.pauseOnAction):f||s.flexAnimate(s.currentSlide,s.vars.pauseOnAction,!0)}t.removeEventListener("touchend",w,!1),a=null,r=null,h=null,c=null},t.addEventListener("touchstart",g,!1))},resize:function(){!s.animating&&s.is(":visible")&&(m||s.doMath(),f?g.smoothHeight():m?(s.slides.width(s.computedW),s.update(s.pagingCount),s.setProps()):d?(s.viewport.height(s.h),s.setProps(s.h,"setTotal")):(s.vars.smoothHeight&&g.smoothHeight(),s.newSlides.width(s.computedW),s.setProps(s.computedW,"setTotal")))},smoothHeight:function(t){if(!d||f){var e=f?s:s.viewport;t?e.animate({height:s.slides.eq(s.animatingTo).innerHeight()},t):e.innerHeight(s.slides.eq(s.animatingTo).innerHeight())}},sync:function(t){var e=n(s.vars.sync).data("flexslider"),i=s.animatingTo;switch(t){case"animate":e.flexAnimate(i,s.vars.pauseOnAction,!1,!0);break;case"play":e.playing||e.asNav||e.play();break;case"pause":e.pause()}},uniqueID:function(t){return t.filter("[id]").add(t.find("[id]")).each(function(){var t=n(this);t.attr("id",t.attr("id")+"_clone")}),t},pauseInvisible:{visProp:null,init:function(){var t=g.pauseInvisible.getHiddenProp();if(t){var e=t.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(e,function(){g.pauseInvisible.isHidden()?s.startTimeout?clearTimeout(s.startTimeout):s.pause():s.started?s.play():s.vars.initDelay>0?setTimeout(s.play,s.vars.initDelay):s.play()})}},isHidden:function(){var t=g.pauseInvisible.getHiddenProp();return!!t&&document[t]},getHiddenProp:function(){var t=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var e=0;es.currentSlide?"next":"prev"),v&&1===s.pagingCount&&(s.direction=s.currentItems.limit&&1!==s.visible?s.limit:y):h=0===s.currentSlide&&t===s.count-1&&s.vars.animationLoop&&"next"!==s.direction?p?(s.count+s.cloneOffset)*w:0:s.currentSlide===s.last&&0===t&&s.vars.animationLoop&&"prev"!==s.direction?p?0:(s.count+1)*w:p?(s.count-1-t+s.cloneOffset)*w:(t+s.cloneOffset)*w,s.setProps(h,"",s.vars.animationSpeed),s.transitions?(s.vars.animationLoop&&s.atEnd||(s.animating=!1,s.currentSlide=s.animatingTo),s.container.unbind("webkitTransitionEnd transitionend"),s.container.bind("webkitTransitionEnd transitionend",function(){clearTimeout(s.ensureAnimationEnd),s.wrapup(w)}),clearTimeout(s.ensureAnimationEnd),s.ensureAnimationEnd=setTimeout(function(){s.wrapup(w)},s.vars.animationSpeed+100)):s.container.animate(s.args,s.vars.animationSpeed,s.vars.easing,function(){s.wrapup(w)})}s.vars.smoothHeight&&g.smoothHeight(s.vars.animationSpeed)}},s.wrapup=function(t){f||m||(0===s.currentSlide&&s.animatingTo===s.last&&s.vars.animationLoop?s.setProps(t,"jumpEnd"):s.currentSlide===s.last&&0===s.animatingTo&&s.vars.animationLoop&&s.setProps(t,"jumpStart")),s.animating=!1,s.currentSlide=s.animatingTo,s.vars.after(s)},s.animateSlides=function(){!s.animating&&o&&s.flexAnimate(s.getTarget("next"))},s.pause=function(){clearInterval(s.animatedSlides),s.animatedSlides=null,s.playing=!1,s.vars.pausePlay&&g.pausePlay.update("play"),s.syncExists&&g.sync("pause")},s.play=function(){s.playing&&clearInterval(s.animatedSlides),s.animatedSlides=s.animatedSlides||setInterval(s.animateSlides,s.vars.slideshowSpeed),s.started=s.playing=!0,s.vars.pausePlay&&g.pausePlay.update("pause"),s.syncExists&&g.sync("play")},s.stop=function(){s.pause(),s.stopped=!0},s.canAdvance=function(t,e){var i=v?s.pagingCount-1:s.last;return!!e||(!(!v||s.currentItem!==s.count-1||0!==t||"prev"!==s.direction)||(!v||0!==s.currentItem||t!==s.pagingCount-1||"next"===s.direction)&&(!(t===s.currentSlide&&!v)&&(!!s.vars.animationLoop||(!s.atEnd||0!==s.currentSlide||t!==i||"next"===s.direction)&&(!s.atEnd||s.currentSlide!==i||0!==t||"next"!==s.direction))))},s.getTarget=function(t){return s.direction=t,"next"===t?s.currentSlide===s.last?0:s.currentSlide+1:0===s.currentSlide?s.last:s.currentSlide-1},s.setProps=function(t,e,i){var n=function(){var i=t?t:(s.itemW+s.vars.itemMargin)*s.move*s.animatingTo,n=function(){if(m)return"setTouch"===e?t:p&&s.animatingTo===s.last?0:p?s.limit-(s.itemW+s.vars.itemMargin)*s.move*s.animatingTo:s.animatingTo===s.last?s.limit:i;switch(e){case"setTotal":return p?(s.count-1-s.currentSlide+s.cloneOffset)*t:(s.currentSlide+s.cloneOffset)*t;case"setTouch":return p?t:t;case"jumpEnd":return p?t:s.count*t;case"jumpStart":return p?s.count*t:t;default:return t}}();return n*-1+"px"}();s.transitions&&(n=d?"translate3d(0,"+n+",0)":"translate3d("+n+",0,0)",i=void 0!==i?i/1e3+"s":"0s",s.container.css("-"+s.pfx+"-transition-duration",i),s.container.css("transition-duration",i)),s.args[s.prop]=n,(s.transitions||void 0===i)&&s.container.css(s.args),s.container.css("transform",n)},s.setup=function(t){if(f)s.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===t&&(c?s.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+s.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(s.currentSlide).css({opacity:1,zIndex:2}):0==s.vars.fadeFirstSlide?s.slides.css({opacity:0,display:"block",zIndex:1}).eq(s.currentSlide).css({zIndex:2}).css({opacity:1}):s.slides.css({opacity:0,display:"block",zIndex:1}).eq(s.currentSlide).css({zIndex:2}).animate({opacity:1},s.vars.animationSpeed,s.vars.easing)),s.vars.smoothHeight&&g.smoothHeight();else{var e,i;"init"===t&&(s.viewport=n('
      ').css({overflow:"hidden",position:"relative"}).appendTo(s).append(s.container),s.cloneCount=0,s.cloneOffset=0,p&&(i=n.makeArray(s.slides).reverse(),s.slides=n(i),s.container.empty().append(s.slides))),s.vars.animationLoop&&!m&&(s.cloneCount=2,s.cloneOffset=1,"init"!==t&&s.container.find(".clone").remove(),s.container.append(g.uniqueID(s.slides.first().clone().addClass("clone")).attr("aria-hidden","true")).prepend(g.uniqueID(s.slides.last().clone().addClass("clone")).attr("aria-hidden","true"))),s.newSlides=n(s.vars.selector,s),e=p?s.count-1-s.currentSlide+s.cloneOffset:s.currentSlide+s.cloneOffset,d&&!m?(s.container.height(200*(s.count+s.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){s.newSlides.css({display:"block"}),s.doMath(),s.viewport.height(s.h),s.setProps(e*s.h,"init")},"init"===t?100:0)):(s.container.width(200*(s.count+s.cloneCount)+"%"),s.setProps(e*s.computedW,"init"),setTimeout(function(){s.doMath(),s.newSlides.css({width:s.computedW,marginRight:s.computedM,"float":"left",display:"block"}),s.vars.smoothHeight&&g.smoothHeight()},"init"===t?100:0))}m||s.slides.removeClass(r+"active-slide").eq(s.currentSlide).addClass(r+"active-slide"),s.vars.init(s)},s.doMath=function(){var t=s.slides.first(),e=s.vars.itemMargin,i=s.vars.minItems,n=s.vars.maxItems;s.w=void 0===s.viewport?s.width():s.viewport.width(),s.h=t.height(),s.boxPadding=t.outerWidth()-t.width(),m?(s.itemT=s.vars.itemWidth+e,s.itemM=e,s.minW=i?i*s.itemT:s.w,s.maxW=n?n*s.itemT-e:s.w,s.itemW=s.minW>s.w?(s.w-e*(i-1))/i:s.maxWs.w?s.w:s.vars.itemWidth,s.visible=Math.floor(s.w/s.itemW),s.move=s.vars.move>0&&s.vars.moves.w?s.itemW*(s.count-1)+e*(s.count-1):(s.itemW+e)*s.count-s.w-e):(s.itemW=s.w,s.itemM=e,s.pagingCount=s.count,s.last=s.count-1),s.computedW=s.itemW-s.boxPadding,s.computedM=s.itemM},s.update=function(t,e){s.doMath(),m||(ts.controlNav.length?g.controlNav.update("add"):("remove"===e&&!m||s.pagingCounts.last&&(s.currentSlide-=1,s.animatingTo-=1),g.controlNav.update("remove",s.last))),s.vars.directionNav&&g.directionNav.update()},s.addSlide=function(t,e){var i=n(t);s.count+=1,s.last=s.count-1,d&&p?void 0!==e?s.slides.eq(s.count-e).after(i):s.container.prepend(i):void 0!==e?s.slides.eq(e).before(i):s.container.append(i),s.update(e,"add"),s.slides=n(s.vars.selector+":not(.clone)",s),s.setup(),s.vars.added(s)},s.removeSlide=function(t){var e=isNaN(t)?s.slides.index(n(t)):t;s.count-=1,s.last=s.count-1,isNaN(t)?n(t,s.slides).remove():d&&p?s.slides.eq(s.last).remove():s.slides.eq(t).remove(),s.doMath(),s.update(e,"remove"),s.slides=n(s.vars.selector+":not(.clone)",s),s.setup(),s.vars.removed(s)},g.init()},n(window).blur(function(t){o=!1}).focus(function(t){o=!0}),n.flexslider.defaults={namespace:"am-",selector:".am-slides > li",animation:"slide",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:5e3,animationSpeed:600,initDelay:0,randomize:!1,fadeFirstSlide:!0,thumbCaptions:!1,pauseOnAction:!0,pauseOnHover:!1,pauseInvisible:!0,useCSS:!0,touch:!0,video:!1,controlNav:!0,directionNav:!0,prevText:" ",nextText:" ",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",customDirectionNav:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:1,maxItems:0,move:0,allowOneSlide:!0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){},init:function(){}},n.fn.flexslider=function(t){var e=Array.prototype.slice.call(arguments,1);if(void 0===t&&(t={}),"object"==typeof t)return this.each(function(){var e=n(this),i=t.selector?t.selector:".am-slides > li",s=e.find(i);1===s.length&&t.allowOneSlide===!1||0===s.length?(s.fadeIn(400),t.start&&t.start(e)):void 0===e.data("flexslider")&&new n.flexslider(this,t)});var i,s=n(this).data("flexslider");switch(t){case"next":s.flexAnimate(s.getTarget("next"),!0);break;case"prev":case"previous":s.flexAnimate(s.getTarget("prev"),!0);break;default:"number"==typeof t?s.flexAnimate(t,!0):"string"==typeof t&&(i="function"==typeof s[t]?s[t].apply(s,e):s[t])}return void 0===i?this:i},s.ready(function(t){n("[data-am-flexslider]",t).each(function(t,e){var i=n(e),o=s.utils.parseOptions(i.data("amFlexslider"));o.before=function(t){t._pausedTimer&&(window.clearTimeout(t._pausedTimer),t._pausedTimer=null)},o.after=function(t){var e=t.vars.playAfterPaused;!e||isNaN(e)||t.playing||t.manualPause||t.manualPlay||t.stopped||(t._pausedTimer=window.setTimeout(function(){t.play()},e))},i.flexslider(o)})}),t.exports=n.flexslider}).call(e,i(12).setImmediate)},function(t,e,i){(function(t,n){function s(t,e){this._id=t,this._clearFn=e}var o=i(13).nextTick,a=Function.prototype.apply,r=Array.prototype.slice,l={},c=0;e.setTimeout=function(){return new s(a.call(setTimeout,window,arguments),clearTimeout)},e.setInterval=function(){return new s(a.call(setInterval,window,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(window,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},e.setImmediate="function"==typeof t?t:function(t){var i=c++,n=!(arguments.length<2)&&r.call(arguments,1);return l[i]=!0,o(function(){l[i]&&(n?t.apply(null,n):t.call(null),e.clearImmediate(i))}),i},e.clearImmediate="function"==typeof n?n:function(t){delete l[t]}}).call(e,i(12).setImmediate,i(12).clearImmediate)},function(t,e){function i(t){if(l===setTimeout)return setTimeout(t,0);try{return l(t,0)}catch(e){try{return l.call(null,t,0)}catch(e){return l.call(this,t,0)}}}function n(t){if(c===clearTimeout)return clearTimeout(t);try{return c(t)}catch(e){try{return c.call(null,t)}catch(e){return c.call(this,t)}}}function s(){p&&h&&(p=!1,h.length?d=h.concat(d):m=-1,d.length&&o())}function o(){if(!p){var t=i(s);p=!0;for(var e=d.length;e;){for(h=d,d=[];++m1)for(var n=1;n0&&(a=s?s/2.5*(c/8):0,l=Math.abs(t)+a,r=l/c),{destination:Math.round(a),duration:r}};var s=t("transform");return e.extend(e,{hasTransform:s!==!1,hasPerspective:t("perspective")in i,hasTouch:"ontouchstart"in window,hasPointer:!(!window.PointerEvent&&!window.MSPointerEvent),hasTransition:t("transition")in i}),e.isBadAndroid=function(){var t=window.navigator.appVersion;if(/Android/.test(t)&&!/Chrome\/\d/.test(t)){var e=t.match(/Safari\/(\d+.\d)/);return!(e&&"object"==typeof e&&e.length>=2)||parseFloat(e[1])<535.19}return!1}(),e.extend(e.style={},{transform:s,transitionTimingFunction:t("transitionTimingFunction"),transitionDuration:t("transitionDuration"),transitionDelay:t("transitionDelay"),transformOrigin:t("transformOrigin")}),e.hasClass=function(t,e){var i=new RegExp("(^|\\s)"+e+"(\\s|$)");return i.test(t.className)},e.addClass=function(t,i){if(!e.hasClass(t,i)){var n=t.className.split(" ");n.push(i),t.className=n.join(" ")}},e.removeClass=function(t,i){if(e.hasClass(t,i)){var n=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(n," ")}},e.offset=function(t){for(var e=-t.offsetLeft,i=-t.offsetTop;t=t.offsetParent;)e-=t.offsetLeft,i-=t.offsetTop;return{left:e,top:i}},e.preventDefaultException=function(t,e){for(var i in e)if(e[i].test(t[i]))return!0;return!1},e.extend(e.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,pointerdown:3,pointermove:3,pointerup:3,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),e.extend(e.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return Math.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var e=4;return(t-=1)*t*((e+1)*t+e)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var e=.22,i=.4;return 0===t?0:1==t?1:i*Math.pow(2,-10*t)*Math.sin((t-e/4)*(2*Math.PI)/e)+1}}}),e.tap=function(t,e){var i=document.createEvent("Event");i.initEvent(e,!0,!0),i.pageX=t.pageX,i.pageY=t.pageY,t.target.dispatchEvent(i)},e.click=function(t){var e,i=t.target;/(SELECT|INPUT|TEXTAREA)/i.test(i.tagName)||(e=document.createEvent(window.MouseEvent?"MouseEvents":"Event"),e.initEvent("click",!0,!0),e.view=t.view||window,e.detail=1,e.screenX=i.screenX||0,e.screenY=i.screenY||0,e.clientX=i.clientX||0,e.clientY=i.clientY||0,e.ctrlKey=!!t.ctrlKey,e.altKey=!!t.altKey,e.shiftKey=!!t.shiftKey,e.metaKey=!!t.metaKey,e.button=0,e.relatedTarget=null,e._constructed=!0,i.dispatchEvent(e))},e}();n.prototype={version:"5.2.0",_init:function(){this._initEvents()},destroy:function(){this._initEvents(!0),clearTimeout(this.resizeTimeout),this.resizeTimeout=null,this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&this.isInTransition&&(this._transitionTime(),this.resetPosition(this.options.bounceTime)||(this.isInTransition=!1,this._execEvent("scrollEnd")))},_start:function(t){if(1!=a.eventType[t.type]){var e;if(e=t.which?t.button:t.button<2?0:4==t.button?1:2,0!==e)return}if(this.enabled&&(!this.initiated||a.eventType[t.type]===this.initiated)){!this.options.preventDefault||a.isBadAndroid||a.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,n=t.touches?t.touches[0]:t;this.initiated=a.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this.startTime=a.getTime(),this.options.useTransition&&this.isInTransition?(this._transitionTime(),this.isInTransition=!1,i=this.getComputedPosition(),this._translate(Math.round(i.x),Math.round(i.y)),this._execEvent("scrollEnd")):!this.options.useTransition&&this.isAnimating&&(this.isAnimating=!1, -this._execEvent("scrollEnd")),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=n.pageX,this.pointY=n.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var e,i,n,s,o=t.touches?t.touches[0]:t,r=o.pageX-this.pointX,l=o.pageY-this.pointY,c=a.getTime();if(this.pointX=o.pageX,this.pointY=o.pageY,this.distX+=r,this.distY+=l,n=Math.abs(this.distX),s=Math.abs(this.distY),!(c-this.endTime>300&&n<10&&s<10)){if(this.directionLocked||this.options.freeScroll||(n>s+this.options.directionLockThreshold?this.directionLocked="h":s>=n+this.options.directionLockThreshold?this.directionLocked="v":this.directionLocked="n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return void(this.initiated=!1);l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return void(this.initiated=!1);r=0}r=this.hasHorizontalScroll?r:0,l=this.hasVerticalScroll?l:0,e=this.x+r,i=this.y+l,(e>0||e0?0:this.maxScrollX),(i>0||i0?0:this.maxScrollY),this.directionX=r>0?-1:r<0?1:0,this.directionY=l>0?-1:l<0?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(e,i),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&a.eventType[t.type]===this.initiated){this.options.preventDefault&&!a.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var e,i,n=(t.changedTouches?t.changedTouches[0]:t,a.getTime()-this.startTime),s=Math.round(this.x),o=Math.round(this.y),r=Math.abs(s-this.startX),l=Math.abs(o-this.startY),c=0,u="";if(this.isInTransition=0,this.initiated=0,this.endTime=a.getTime(),!this.resetPosition(this.options.bounceTime))return this.scrollTo(s,o),this.moved?this._events.flick&&n<200&&r<100&&l<100?void this._execEvent("flick"):(this.options.momentum&&n<300&&(e=this.hasHorizontalScroll?a.momentum(this.x,this.startX,n,this.maxScrollX,this.options.bounce?this.wrapperWidth:0,this.options.deceleration):{destination:s,duration:0},i=this.hasVerticalScroll?a.momentum(this.y,this.startY,n,this.maxScrollY,this.options.bounce?this.wrapperHeight:0,this.options.deceleration):{destination:o,duration:0},s=e.destination,o=i.destination,c=Math.max(e.duration,i.duration),this.isInTransition=1),s!=this.x||o!=this.y?((s>0||s0||o0?e=0:this.x0?i=0:this.y-1&&this._events[t].splice(i,1)}},_execEvent:function(t){if(this._events[t]){var e=0,i=this._events[t].length;if(i)for(;e0;var s=this.options.useTransition&&n.style;!i||s?(s&&(this._transitionTimingFunction(n.style),this._transitionTime(i)),this._translate(t,e)):this._animate(t,e,i,n.fn)},scrollToElement:function(t,e,i,n,s){if(t=t.nodeType?t:this.scroller.querySelector(t)){var o=a.offset(t);o.left-=this.wrapperOffset.left,o.top-=this.wrapperOffset.top,i===!0&&(i=Math.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),n===!0&&(n=Math.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),o.left-=i||0,o.top-=n||0,o.left=o.left>0?0:o.left0?0:o.top=h?(r.isAnimating=!1,r._translate(t,e),void(r.resetPosition(r.options.bounceTime)||r._execEvent("scrollEnd"))):(f=(f-u)/i,m=n(f),d=(t-l)*m+l,p=(e-c)*m+c,r._translate(d,p),void(r.isAnimating&&o(s)))}var r=this,l=this.x,c=this.y,u=a.getTime(),h=u+i;this.isAnimating=!0,s()},handleEvent:function(t){switch(t.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"wheel":case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t);break;case"click":this.enabled&&!t._constructed&&(t.preventDefault(),t.stopPropagation())}}},n.utils=a,t.exports=s.iScroll=n},function(t,e,i){"use strict";function n(t,e){return this.each(function(){var i=s(this),n=i.data("amui.modal"),o="object"==typeof t&&t;n||i.data("amui.modal",n=new c(this,o)),"string"==typeof t?n[t]&&n[t](e):n.toggle(t&&t.relatedTarget||void 0)})}var s=i(1),o=i(2),a=i(9),r=s(document),l=o.support.transition,c=function(t,e){this.options=s.extend({},c.DEFAULTS,e||{}),this.$element=s(t),this.$dialog=this.$element.find(".am-modal-dialog"),this.$element.attr("id")||this.$element.attr("id",o.utils.generateGUID("am-modal")),this.isPopup=this.$element.hasClass("am-popup"),this.isActions=this.$element.hasClass("am-modal-actions"),this.isPrompt=this.$element.hasClass("am-modal-prompt"),this.isLoading=this.$element.hasClass("am-modal-loading"),this.active=this.transitioning=this.relatedTarget=null,this.dimmer=this.options.dimmer?a:{open:function(){},close:function(){}},this.events()};c.DEFAULTS={className:{active:"am-modal-active",out:"am-modal-out"},selector:{modal:".am-modal",active:".am-modal-active"},closeViaDimmer:!0,cancelable:!0,onConfirm:function(){},onCancel:function(){},closeOnCancel:!0,closeOnConfirm:!0,dimmer:!0,height:void 0,width:void 0,duration:300,transitionEnd:l&&l.end+".modal.amui"},c.prototype.toggle=function(t){return this.active?this.close():this.open(t)},c.prototype.open=function(t){var e=this.$element,i=this.options,n=this.isPopup,o=i.width,a=i.height,r={};if(!this.active&&this.$element.length){t&&(this.relatedTarget=t),this.transitioning&&(clearTimeout(e.transitionEndTimmer),e.transitionEndTimmer=null,e.trigger(i.transitionEnd).off(i.transitionEnd)),n&&this.$element.show(),this.active=!0,e.trigger(s.Event("open.modal.amui",{relatedTarget:t})),this.dimmer.open(e),e.show().redraw(),n||this.isActions||(o&&(r.width=parseInt(o,10)+"px"),a&&(r.height=parseInt(a,10)+"px"),this.$dialog.css(r)),e.removeClass(i.className.out).addClass(i.className.active),this.transitioning=1;var c=function(){e.trigger(s.Event("opened.modal.amui",{relatedTarget:t})),this.transitioning=0,this.isPrompt&&this.$dialog.find("input").eq(0).focus()};return l?void e.one(i.transitionEnd,s.proxy(c,this)).emulateTransitionEnd(i.duration):c.call(this)}},c.prototype.close=function(t){if(this.active){var e=this.$element,i=this.options,n=this.isPopup;this.transitioning&&(clearTimeout(e.transitionEndTimmer),e.transitionEndTimmer=null,e.trigger(i.transitionEnd).off(i.transitionEnd),this.dimmer.close(e,!0)),this.$element.trigger(s.Event("close.modal.amui",{relatedTarget:t})),this.transitioning=1;var o=function(){e.trigger("closed.modal.amui"),n&&e.removeClass(i.className.out),e.hide(),this.transitioning=0,this.dimmer.close(e,!1),this.active=!1};return e.removeClass(i.className.active).addClass(i.className.out),l?void e.one(i.transitionEnd,s.proxy(o,this)).emulateTransitionEnd(i.duration):o.call(this)}},c.prototype.events=function(){var t=this,e=this.options,i=this.$element,n=this.dimmer.$element,o=i.find(".am-modal-prompt-input"),a=i.find("[data-am-modal-confirm]"),r=i.find("[data-am-modal-cancel]"),l=function(){var t=[];return o.each(function(){t.push(s(this).val())}),0===t.length?void 0:1===t.length?t[0]:t};this.options.cancelable&&i.on("keyup.modal.amui",function(e){t.active&&27===e.which&&(i.trigger("cancel.modal.amui"),t.close())}),this.options.dimmer&&this.options.closeViaDimmer&&!this.isLoading&&n.on("click.dimmer.modal.amui",function(){t.close()}),i.on("click.close.modal.amui","[data-am-modal-close], .am-modal-btn",function(i){i.preventDefault();var n=s(this);n.is(a)?e.closeOnConfirm&&t.close():n.is(r)?e.closeOnCancel&&t.close():t.close()}).on("click",function(t){s(t.target).is(i)&&n.trigger("click.dimmer.modal.amui")}),a.on("click.confirm.modal.amui",function(){i.trigger(s.Event("confirm.modal.amui",{trigger:this}))}),r.on("click.cancel.modal.amui",function(){i.trigger(s.Event("cancel.modal.amui",{trigger:this}))}),i.on("confirm.modal.amui",function(e){e.data=l(),t.options.onConfirm.call(t,e)}).on("cancel.modal.amui",function(e){e.data=l(),t.options.onCancel.call(t,e)})},s.fn.modal=n,r.on("click.modal.amui.data-api","[data-am-modal]",function(){var t=s(this),e=o.utils.parseOptions(t.attr("data-am-modal")),i=s(e.target||this.href&&this.href.replace(/.*(?=#[^\s]+$)/,"")),a=i.data("amui.modal")?"toggle":e;n.call(i,a,this)}),t.exports=o.modal=c},function(t,e,i){"use strict";function n(t,e){var i=Array.prototype.slice.call(arguments,1);return this.each(function(){var n=s(this),o=n.data("amui.offcanvas"),a=s.extend({},"object"==typeof t&&t);o||(n.data("amui.offcanvas",o=new c(this,a)),(!t||"object"==typeof t)&&o.open(e)),"string"==typeof t&&o[t]&&o[t].apply(o,i)})}var s=i(1),o=i(2);i(3);var a,r=s(window),l=s(document),c=function(t,e){this.$element=s(t),this.options=s.extend({},c.DEFAULTS,e),this.active=null,this.bindEvents()};c.DEFAULTS={duration:300,effect:"overlay"},c.prototype.open=function(t){var e=this,i=this.$element;if(i.length&&!i.hasClass("am-active")){var n=this.options.effect,o=s("html"),l=s("body"),c=i.find(".am-offcanvas-bar").first(),u=c.hasClass("am-offcanvas-bar-flip")?-1:1;c.addClass("am-offcanvas-bar-"+n),a={x:window.scrollX,y:window.scrollY},i.addClass("am-active"),l.css({width:window.innerWidth,height:r.height()}).addClass("am-offcanvas-page"),"overlay"!==n&&l.css({"margin-left":c.outerWidth()*u}).width(),o.css("margin-top",a.y*-1),setTimeout(function(){c.addClass("am-offcanvas-bar-active").width()},0),i.trigger("open.offcanvas.amui"),this.active=1,i.on("click.offcanvas.amui",function(t){var i=s(t.target);i.hasClass("am-offcanvas-bar")||i.parents(".am-offcanvas-bar").first().length||(t.stopImmediatePropagation(),e.close())}),o.on("keydown.offcanvas.amui",function(t){27===t.keyCode&&e.close()})}},c.prototype.close=function(t){function e(){r.removeClass("am-offcanvas-page").css({width:"",height:"","margin-left":"","margin-right":""}),l.removeClass("am-active"),c.removeClass("am-offcanvas-bar-active"),n.css("margin-top",""),window.scrollTo(a.x,a.y),l.trigger("closed.offcanvas.amui"),i.active=0}var i=this,n=s("html"),r=s("body"),l=this.$element,c=l.find(".am-offcanvas-bar").first();l.length&&this.active&&l.hasClass("am-active")&&(l.trigger("close.offcanvas.amui"),o.support.transition?(setTimeout(function(){c.removeClass("am-offcanvas-bar-active")},0),r.css("margin-left","").one(o.support.transition.end,function(){e()}).emulateTransitionEnd(this.options.duration)):e(),l.off("click.offcanvas.amui"),n.off(".offcanvas.amui"))},c.prototype.bindEvents=function(){var t=this;return l.on("click.offcanvas.amui",'[data-am-dismiss="offcanvas"]',function(e){e.preventDefault(),t.close()}),r.on("resize.offcanvas.amui orientationchange.offcanvas.amui",function(){t.active&&t.close()}),this.$element.hammer().on("swipeleft swipeleft",function(e){e.preventDefault(),t.close()}),this},s.fn.offCanvas=n,l.on("click.offcanvas.amui","[data-am-offcanvas]",function(t){t.preventDefault();var e=s(this),i=o.utils.parseOptions(e.data("amOffcanvas")),a=s(i.target||this.href&&this.href.replace(/.*(?=#[^\s]+$)/,"")),r=a.data("amui.offcanvas")?"open":i;n.call(a,r,this)}),t.exports=o.offcanvas=c},function(t,e,i){"use strict";var n=i(1),s=i(2),o=s.utils.rAF,a=function(t){var e=function(e,i){this.el=t(e),this.zoomFactor=1,this.lastScale=1,this.offset={x:0,y:0},this.options=t.extend({},this.defaults,i),this.setupMarkup(),this.bindEvents(),this.update(),this.enable()},i=function(t,e){return t+e},n=function(t,e){return t>e-.01&&t1){var e=this.getTouches(t)[0];this.drag(e,this.lastDragPosition),this.offset=this.sanitizeOffset(this.offset),this.lastDragPosition=e}},handleDragEnd:function(){this.el.trigger(this.options.dragEndEventName),this.end()},handleZoomStart:function(t){this.el.trigger(this.options.zoomStartEventName),this.stopAnimation(),this.lastScale=1,this.nthZoom=0,this.lastZoomCenter=!1,this.hasInteraction=!0},handleZoom:function(t,e){var i=this.getTouchCenter(this.getTouches(t)),n=e/this.lastScale;this.lastScale=e,this.nthZoom+=1,this.nthZoom>3&&(this.scale(n,i),this.drag(i,this.lastZoomCenter)),this.lastZoomCenter=i},handleZoomEnd:function(){this.el.trigger(this.options.zoomEndEventName),this.end()},handleDoubleTap:function(t){var e=this.getTouches(t)[0],i=this.zoomFactor>1?1:this.options.tapZoomFactor,n=this.zoomFactor,s=function(t){this.scaleTo(n+t*(i-n),e)}.bind(this);this.hasInteraction||(n>i&&(e=this.getCurrentZoomCenter()),this.animate(this.options.animationDuration,s,this.swing),this.el.trigger(this.options.doubleTapEventName))},sanitizeOffset:function(t){var e=(this.zoomFactor-1)*this.getContainerX(),i=(this.zoomFactor-1)*this.getContainerY(),n=Math.max(e,0),s=Math.max(i,0),o=Math.min(e,0),a=Math.min(i,0);return{x:Math.min(Math.max(t.x,o),n),y:Math.min(Math.max(t.y,a),s)}},scaleTo:function(t,e){this.scale(t/this.zoomFactor,e)},scale:function(t,e){t=this.scaleZoomFactor(t),this.addOffset({x:(t-1)*(e.x+this.offset.x),y:(t-1)*(e.y+this.offset.y)})},scaleZoomFactor:function(t){var e=this.zoomFactor;return this.zoomFactor*=t,this.zoomFactor=Math.min(this.options.maxZoom,Math.max(this.zoomFactor,this.options.minZoom)),this.zoomFactor/e},drag:function(t,e){e&&(this.options.lockDragAxis?Math.abs(t.x-e.x)>Math.abs(t.y-e.y)?this.addOffset({x:-(t.x-e.x),y:0}):this.addOffset({y:-(t.y-e.y),x:0}):this.addOffset({y:-(t.y-e.y),x:-(t.x-e.x)}))},getTouchCenter:function(t){return this.getVectorAvg(t)},getVectorAvg:function(t){return{x:t.map(function(t){return t.x}).reduce(i)/t.length,y:t.map(function(t){return t.y}).reduce(i)/t.length}},addOffset:function(t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y}},sanitize:function(){this.zoomFactor=t?(e(1),n&&n(),this.update(),this.stopAnimation(),this.update()):(i&&(l=i(l)),e(l),this.update(),o(a))}}.bind(this);this.inAnimation=!0,o(a)},stopAnimation:function(){this.inAnimation=!1},swing:function(t){return-Math.cos(t*Math.PI)/2+.5},getContainerX:function(){return this.container[0].offsetWidth},getContainerY:function(){return this.container[0].offsetHeight},setContainerY:function(t){return this.container.height(t)},setupMarkup:function(){this.container=t('
      '),this.el.before(this.container),this.container.append(this.el),this.container.css({overflow:"hidden",position:"relative"}),this.el.css({"-webkit-transform-origin":"0% 0%","-moz-transform-origin":"0% 0%","-ms-transform-origin":"0% 0%","-o-transform-origin":"0% 0%","transform-origin":"0% 0%",position:"absolute"})},end:function(){this.hasInteraction=!1,this.sanitize(),this.update()},bindEvents:function(){s(this.container.get(0),this),t(window).on("resize",this.update.bind(this)),t(this.el).find("img").on("load",this.update.bind(this))},update:function(){this.updatePlaned||(this.updatePlaned=!0,setTimeout(function(){this.updatePlaned=!1,this.updateAspectRatio();var t=this.getInitialZoomFactor()*this.zoomFactor,e=-this.offset.x/t,i=-this.offset.y/t,n="scale3d("+t+", "+t+",1) translate3d("+e+"px,"+i+"px,0px)",s="scale("+t+", "+t+") translate("+e+"px,"+i+"px)",o=function(){this.clone&&(this.clone.remove(),delete this.clone)}.bind(this);!this.options.use2d||this.hasInteraction||this.inAnimation?(this.is3d=!0,o(),this.el.css({"-webkit-transform":n,"-o-transform":s,"-ms-transform":s,"-moz-transform":s,transform:n})):(this.is3d&&(this.clone=this.el.clone(),this.clone.css("pointer-events","none"),this.clone.appendTo(this.container),setTimeout(o,200)),this.el.css({"-webkit-transform":s,"-o-transform":s,"-ms-transform":s,"-moz-transform":s,transform:s}),this.is3d=!1)}.bind(this),0))},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1}};var s=function(t,e){var i=null,n=0,s=null,o=null,a=function(t,n){if(i!==t){if(i&&!t)switch(i){case"zoom":e.handleZoomEnd(n);break;case"drag":e.handleDragEnd(n)}switch(t){case"zoom":e.handleZoomStart(n);break;case"drag":e.handleDragStart(n)}}i=t},r=function(t){2===n?a("zoom"):1===n&&e.canDrag()?a("drag",t):a(null,t)},l=function(t){return Array.prototype.slice.call(t).map(function(t){return{x:t.pageX,y:t.pageY}})},c=function(t,e){var i,n;return i=t.x-e.x,n=t.y-e.y,Math.sqrt(i*i+n*n)},u=function(t,e){var i=c(t[0],t[1]),n=c(e[0],e[1]);return n/i},h=function(t){t.stopPropagation(),t.preventDefault()},d=function(t){var o=(new Date).getTime();if(n>1&&(s=null),o-s<300)switch(h(t),e.handleDoubleTap(t),i){case"zoom":e.handleZoomEnd(t);break;case"drag":e.handleDragEnd(t)}1===n&&(s=o)},p=!0;t.addEventListener("touchstart",function(t){e.enabled&&(p=!0,n=t.touches.length,d(t))}),t.addEventListener("touchmove",function(t){if(e.enabled){if(p)r(t),i&&h(t),o=l(t.touches);else{switch(i){case"zoom":e.handleZoom(t,u(o,l(t.touches)));break;case"drag":e.handleDrag(t)}i&&(h(t),e.update())}p=!1}}),t.addEventListener("touchend",function(t){e.enabled&&(n=t.touches.length,r(t))})};return e};t.exports=s.pichzoom=a(n)},function(t,e,i){"use strict";var n=i(1),s=i(2),o=n(window),a=function(t,e){this.options=n.extend({},a.DEFAULTS,e),this.$element=n(t),this.active=null,this.$popover=this.options.target&&n(this.options.target)||null,this.init(),this._bindEvents()};a.DEFAULTS={theme:null,trigger:"click",content:"",open:!1,target:null,tpl:'
      '},a.prototype.init=function(){function t(){i.sizePopover()}var e,i=this,o=this.$element;this.options.target||(this.$popover=this.getPopover(),this.setContent()),e=this.$popover,e.appendTo(n("body")),this.sizePopover(),o.on("open.popover.amui",function(){n(window).on("resize.popover.amui",s.utils.debounce(t,50))}),o.on("close.popover.amui",function(){n(window).off("resize.popover.amui",t)}),this.options.open&&this.open()},a.prototype.sizePopover=function(){var t=this.$element,e=this.$popover;if(e&&e.length){var i=e.outerWidth(),n=e.outerHeight(),s=e.find(".am-popover-caret"),a=s.outerWidth()/2||8,r=n+8,l=t.outerWidth(),c=t.outerHeight(),u=t.offset(),h=t[0].getBoundingClientRect(),d=o.height(),p=o.width(),m=0,f=0,v=0,g=2,y="top";e.css({left:"",top:""}).removeClass("am-popover-left am-popover-right am-popover-top am-popover-bottom"),r-gp&&(f=p-i-20),"top"===y&&e.addClass("am-popover-top"),"bottom"===y&&e.addClass("am-popover-bottom"),v-=f):"middle"===y&&(f=u.left-i-a,e.addClass("am-popover-left"),f<5&&(f=u.left+l+a,e.removeClass("am-popover-left").addClass("am-popover-right")),f+i>p&&(f=p-i-5,e.removeClass("am-popover-left").addClass("am-popover-right"))),e.css({top:m+"px",left:f+"px"})}},a.prototype.toggle=function(){return this[this.active?"close":"open"]()},a.prototype.open=function(){var t=this.$popover;this.$element.trigger("open.popover.amui"),this.sizePopover(),t.show().addClass("am-active"),this.active=!0},a.prototype.close=function(){var t=this.$popover;this.$element.trigger("close.popover.amui"),t.removeClass("am-active").trigger("closed.popover.amui").hide(),this.active=!1},a.prototype.getPopover=function(){var t=s.utils.generateGUID("am-popover"),e=[];return this.options.theme&&n.each(this.options.theme.split(" "),function(t,i){e.push("am-popover-"+n.trim(i))}),n(this.options.tpl).attr("id",t).addClass(e.join(" "))},a.prototype.setContent=function(t){t=t||this.options.content,this.$popover&&this.$popover.find(".am-popover-inner").empty().html(t)},a.prototype._bindEvents=function(){for(var t="popover.amui",e=this.options.trigger.split(" "),i=e.length;i--;){var s=e[i];if("click"===s)this.$element.on("click."+t,n.proxy(this.toggle,this));else{var o="hover"==s?"mouseenter":"focusin",a="hover"==s?"mouseleave":"focusout";this.$element.on(o+"."+t,n.proxy(this.open,this)),this.$element.on(a+"."+t,n.proxy(this.close,this))}}},a.prototype.destroy=function(){this.$element.off(".popover.amui").removeData("amui.popover"),this.$popover.remove()},s.plugin("popover",a),s.ready(function(t){n("[data-am-popover]",t).popover()}),t.exports=a},function(t,e,i){"use strict";var n=i(2),s=function(){function t(t,e,i){return ti?i:t}function e(t){return 100*(-1+t)}function i(t,i,n){var s;return s="translate3d"===c.positionUsing?{transform:"translate3d("+e(t)+"%,0,0)"}:"translate"===c.positionUsing?{transform:"translate("+e(t)+"%,0)"}:{"margin-left":e(t)+"%"},s.transition="all "+i+"ms "+n,s}function n(t,e){var i="string"==typeof t?t:a(t);return i.indexOf(" "+e+" ")>=0}function s(t,e){var i=a(t),s=i+e;n(i,e)||(t.className=s.substring(1))}function o(t,e){var i,s=a(t);n(t,e)&&(i=s.replace(" "+e+" "," "),t.className=i.substring(1,i.length-1))}function a(t){return(" "+(t.className||"")+" ").replace(/\s+/gi," ")}function r(t){t&&t.parentNode&&t.parentNode.removeChild(t)}var l={};l.version="0.2.0";var c=l.settings={minimum:.08,easing:"ease",positionUsing:"",speed:200,trickle:!0,trickleRate:.02,trickleSpeed:800,showSpinner:!0,parent:"body",barSelector:'[role="nprogress-bar"]',spinnerSelector:'[role="nprogress-spinner"]',template:'
      '};l.configure=function(t){var e,i;for(e in t)i=t[e],void 0!==i&&t.hasOwnProperty(e)&&(c[e]=i);return this},l.status=null,l.set=function(e){var n=l.isStarted();e=t(e,c.minimum,1),l.status=1===e?null:e;var s=l.render(!n),o=s.querySelector(c.barSelector),a=c.speed,r=c.easing;return s.offsetWidth,u(function(t){""===c.positionUsing&&(c.positionUsing=l.getPositioningCSS()),h(o,i(e,a,r)),1===e?(h(s,{transition:"none",opacity:1}),s.offsetWidth,setTimeout(function(){h(s,{transition:"all "+a+"ms linear",opacity:0}),setTimeout(function(){l.remove(),t()},a)},a)):setTimeout(t,a)}),this},l.isStarted=function(){return"number"==typeof l.status},l.start=function(){l.status||l.set(0);var t=function(){setTimeout(function(){l.status&&(l.trickle(),t())},c.trickleSpeed)};return c.trickle&&t(),this},l.done=function(t){return t||l.status?l.inc(.3+.5*Math.random()).set(1):this},l.inc=function(e){var i=l.status;return i?("number"!=typeof e&&(e=(1-i)*t(Math.random()*i,.1,.95)),i=t(i+e,0,.994),l.set(i)):l.start()},l.trickle=function(){return l.inc(Math.random()*c.trickleRate)},function(){var t=0,e=0;l.promise=function(i){return i&&"resolved"!==i.state()?(0===e&&l.start(),t++,e++,i.always(function(){e--,0===e?(t=0,l.done()):l.set((t-e)/t)}),this):this}}(),l.render=function(t){if(l.isRendered())return document.getElementById("nprogress");s(document.documentElement,"nprogress-busy");var i=document.createElement("div");i.id="nprogress",i.innerHTML=c.template;var n,o=i.querySelector(c.barSelector),a=t?"-100":e(l.status||0),u=document.querySelector(c.parent);return h(o,{transition:"all 0 linear",transform:"translate3d("+a+"%,0,0)"}),c.showSpinner||(n=i.querySelector(c.spinnerSelector),n&&r(n)),u!=document.body&&s(u,"nprogress-custom-parent"),u.appendChild(i),i},l.remove=function(){o(document.documentElement,"nprogress-busy"),o(document.querySelector(c.parent),"nprogress-custom-parent");var t=document.getElementById("nprogress");t&&r(t)},l.isRendered=function(){return!!document.getElementById("nprogress")},l.getPositioningCSS=function(){var t=document.body.style,e="WebkitTransform"in t?"Webkit":"MozTransform"in t?"Moz":"msTransform"in t?"ms":"OTransform"in t?"O":"";return e+"Perspective"in t?"translate3d":e+"Transform"in t?"translate":"margin"};var u=function(){function t(){var i=e.shift();i&&i(t)}var e=[];return function(i){e.push(i),1==e.length&&t()}}(),h=function(){function t(t){return t.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(t,e){return e.toUpperCase()})}function e(t){var e=document.body.style;if(t in e)return t;for(var i,n=s.length,o=t.charAt(0).toUpperCase()+t.slice(1);n--;)if(i=s[n]+o,i in e)return i;return t}function i(i){return i=t(i),o[i]||(o[i]=e(i))}function n(t,e,n){e=i(e),t.style[e]=n}var s=["Webkit","O","Moz","ms"],o={};return function(t,e){var i,s,o=arguments;if(2==o.length)for(i in e)s=e[i],void 0!==s&&e.hasOwnProperty(i)&&n(t,i,s);else n(t,o[1],o[2])}}();return l}();t.exports=n.progress=s},function(t,e,i){"use strict";var n=i(1),s=i(2),o=i(17),a=i(3),r=s.support.animation,l=s.support.transition,c=function(t,e){this.$element=n(t),this.$body=n(document.body),this.options=n.extend({},c.DEFAULTS,e),this.$pureview=n(this.options.tpl).attr("id",s.utils.generateGUID("am-pureview")),this.$slides=null,this.transitioning=null,this.scrollbarWidth=0,this.init()};c.DEFAULTS={tpl:'
          /
          ',className:{prevSlide:"am-pureview-slide-prev",nextSlide:"am-pureview-slide-next",onlyOne:"am-pureview-only",active:"am-active",barActive:"am-pureview-bar-active",activeBody:"am-pureview-active"},selector:{slider:".am-pureview-slider",close:'[data-am-close="pureview"]',total:".am-pureview-total",current:".am-pureview-current",title:".am-pureview-title",actions:".am-pureview-actions", -bar:".am-pureview-bar",pinchZoom:".am-pinch-zoom",nav:".am-pureview-nav"},shareBtn:!1,toggleToolbar:!0,target:"img",weChatImagePreview:!0},c.prototype.init=function(){var t=this,e=this.options,i=this.$element,s=this.$pureview;this.refreshSlides(),n("body").append(s),this.$title=s.find(e.selector.title),this.$current=s.find(e.selector.current),this.$bar=s.find(e.selector.bar),this.$actions=s.find(e.selector.actions),e.shareBtn&&this.$actions.append(''),this.$element.on("click.pureview.amui",e.target,function(i){i.preventDefault();var n=t.$images.index(this);e.weChatImagePreview&&window.WeixinJSBridge?window.WeixinJSBridge.invoke("imagePreview",{current:t.imgUrls[n],urls:t.imgUrls}):t.open(n)}),s.find(".am-pureview-direction").on("click.direction.pureview.amui","li",function(e){e.preventDefault(),n(this).is(".am-pureview-prev")?t.prevSlide():t.nextSlide()}),s.find(e.selector.nav).on("click.nav.pureview.amui","li",function(){var e=t.$navItems.index(n(this));t.activate(t.$slides.eq(e))}),s.find(e.selector.close).on("click.close.pureview.amui",function(e){e.preventDefault(),t.close()}),this.$slider.hammer().on("swipeleft.pureview.amui",function(e){e.preventDefault(),t.nextSlide()}).on("swiperight.pureview.amui",function(e){e.preventDefault(),t.prevSlide()}).on("press.pureview.amui",function(i){i.preventDefault(),e.toggleToolbar&&t.toggleToolBar()}),this.$slider.data("hammer").get("swipe").set({direction:a.DIRECTION_HORIZONTAL,velocity:.35}),i.DOMObserve({childList:!0,subtree:!0},function(t,e){}),i.on("changed.dom.amui",function(e){e.stopPropagation(),t.refreshSlides()}),n(document).on("keydown.pureview.amui",n.proxy(function(t){var e=t.keyCode;37==e?this.prevSlide():39==e?this.nextSlide():27==e&&this.close()},this))},c.prototype.refreshSlides=function(){this.$images=this.$element.find(this.options.target);var t=this,e=this.options,i=this.$pureview,o=n([]),a=n([]),r=this.$images,l=r.length;this.$slider=i.find(e.selector.slider),this.$nav=i.find(e.selector.nav);var c="data-am-pureviewed";this.imgUrls=this.imgUrls||[],l&&(1===l&&i.addClass(e.className.onlyOne),r.not("["+c+"]").each(function(e,i){var r,l;"A"===i.nodeName?(r=i.href,l=i.title||""):(r=n(i).data("rel")||i.src,r=s.utils.getAbsoluteUrl(r),l=n(i).attr("alt")||""),i.setAttribute(c,"1"),t.imgUrls.push(r),o=o.add(n('
        1. ')),a=a.add(n("
        2. "+(e+1)+"
        3. "))}),i.find(e.selector.total).text(l),this.$slider.append(o),this.$nav.append(a),this.$navItems=this.$nav.find("li"),this.$slides=this.$slider.find("li"))},c.prototype.loadImage=function(t,e){var i="image-appended";if(!t.data(i)){var s=n("",{src:t.data("src"),alt:t.data("title")});t.html(s).wrapInner('
          ').redraw();var a=t.find(this.options.selector.pinchZoom);a.data("amui.pinchzoom",new o(a[0],{})),t.data("image-appended",!0)}e&&e.call(this)},c.prototype.activate=function(t){var e=this.options,i=this.$slides,o=i.index(t),a=t.data("title")||"",r=e.className.active;i.find("."+r).is(t)||this.transitioning||(this.loadImage(t,function(){s.utils.imageLoader(t.find("img"),function(e){t.find(".am-pinch-zoom").addClass("am-pureview-loaded"),n(e).addClass("am-img-loaded")})}),this.transitioning=1,this.$title.text(a),this.$current.text(o+1),i.removeClass(),t.addClass(r),i.eq(o-1).addClass(e.className.prevSlide),i.eq(o+1).addClass(e.className.nextSlide),this.$navItems.removeClass().eq(o).addClass(e.className.active),l?t.one(l.end,n.proxy(function(){this.transitioning=0},this)).emulateTransitionEnd(300):this.transitioning=0)},c.prototype.nextSlide=function(){if(1!==this.$slides.length){var t=this.$slides,e=t.filter(".am-active"),i=t.index(e),n="am-animation-right-spring";i+1>=t.length?r&&e.addClass(n).on(r.end,function(){e.removeClass(n)}):this.activate(t.eq(i+1))}},c.prototype.prevSlide=function(){if(1!==this.$slides.length){var t=this.$slides,e=t.filter(".am-active"),i=this.$slides.index(e),n="am-animation-left-spring";0===i?r&&e.addClass(n).on(r.end,function(){e.removeClass(n)}):this.activate(t.eq(i-1))}},c.prototype.toggleToolBar=function(){this.$pureview.toggleClass(this.options.className.barActive)},c.prototype.open=function(t){var e=t||0;this.checkScrollbar(),this.setScrollbar(),this.activate(this.$slides.eq(e)),this.$pureview.show().redraw().addClass(this.options.className.active),this.$body.addClass(this.options.className.activeBody)},c.prototype.close=function(){function t(){this.$pureview.hide(),this.$body.removeClass(e.className.activeBody),this.resetScrollbar()}var e=this.options;this.$pureview.removeClass(e.className.active),this.$slides.removeClass(),l?this.$pureview.one(l.end,n.proxy(t,this)).emulateTransitionEnd(300):t.call(this)},c.prototype.checkScrollbar=function(){this.scrollbarWidth=s.utils.measureScrollbar()},c.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.scrollbarWidth&&this.$body.css("padding-right",t+this.scrollbarWidth)},c.prototype.resetScrollbar=function(){this.$body.css("padding-right","")},s.plugin("pureview",c),s.ready(function(t){n("[data-am-pureview]",t).pureview()}),t.exports=c},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){if(s.support.animation){this.options=n.extend({},o.DEFAULTS,e),this.$element=n(t);var i=function(){s.utils.rAF.call(window,n.proxy(this.checkView,this))}.bind(this);this.$window=n(window).on("scroll.scrollspy.amui",i).on("resize.scrollspy.amui orientationchange.scrollspy.amui",s.utils.debounce(i,50)),this.timer=this.inViewState=this.initInView=null,i()}};o.DEFAULTS={animation:"fade",className:{inView:"am-scrollspy-inview",init:"am-scrollspy-init"},repeat:!0,delay:0,topOffset:0,leftOffset:0},o.prototype.checkView=function(){var t=this.$element,e=this.options,i=s.utils.isInView(t,e),n=e.animation?" am-animation-"+e.animation:"";i&&!this.inViewState&&(this.timer&&clearTimeout(this.timer),this.initInView||(t.addClass(e.className.init),this.offset=t.offset(),this.initInView=!0,t.trigger("init.scrollspy.amui")),this.timer=setTimeout(function(){i&&t.addClass(e.className.inView+n).width()},e.delay),this.inViewState=!0,t.trigger("inview.scrollspy.amui")),!i&&this.inViewState&&e.repeat&&(t.removeClass(e.className.inView+n),this.inViewState=!1,t.trigger("outview.scrollspy.amui"))},o.prototype.check=function(){s.utils.rAF.call(window,n.proxy(this.checkView,this))},s.plugin("scrollspy",o),s.ready(function(t){n("[data-am-scrollspy]",t).scrollspy()}),t.exports=o},function(t,e,i){"use strict";var n=i(1),s=i(2);i(23);var o=function(t,e){this.options=n.extend({},o.DEFAULTS,e),this.$element=n(t),this.anchors=[],this.$links=this.$element.find('a[href^="#"]').each(function(t,e){this.anchors.push(n(e).attr("href"))}.bind(this)),this.$targets=n(this.anchors.join(", "));var i=function(){s.utils.rAF.call(window,n.proxy(this.process,this))}.bind(this);this.$window=n(window).on("scroll.scrollspynav.amui",i).on("resize.scrollspynav.amui orientationchange.scrollspynav.amui",s.utils.debounce(i,50)),i(),this.scrollProcess()};o.DEFAULTS={className:{active:"am-active"},closest:!1,smooth:!0,offsetTop:0},o.prototype.process=function(){var t=this.$window.scrollTop(),e=this.options,i=[],o=this.$links,a=this.$targets;if(a.each(function(t,n){s.utils.isInView(n,e)&&i.push(n)}),i.length){var r;if(n.each(i,function(e,i){if(n(i).offset().top>=t)return r=n(i),!1}),!r)return;e.closest?(o.closest(e.closest).removeClass(e.className.active),o.filter('a[href="#'+r.attr("id")+'"]').closest(e.closest).addClass(e.className.active)):o.removeClass(e.className.active).filter('a[href="#'+r.attr("id")+'"]').addClass(e.className.active)}},o.prototype.scrollProcess=function(){var t=this.$links,e=this.options;e.smooth&&n.fn.smoothScroll&&t.on("click",function(t){t.preventDefault();var i=n(this),s=n(i.attr("href"));if(s){var o=e.offsetTop&&!isNaN(parseInt(e.offsetTop))&&parseInt(e.offsetTop)||0;n(window).smoothScroll({position:s.offset().top-o})}})},s.plugin("scrollspynav",o),s.ready(function(t){n("[data-am-scrollspynav]",t).scrollspynav()}),t.exports=o},function(t,e,i){"use strict";var n=i(1),s=i(2),o=s.utils.rAF,a=s.utils.cancelAF,r=!1,l=function(t,e){function i(t){return(t/=.5)<1?.5*Math.pow(t,5):.5*(Math.pow(t-2,5)+2)}function s(){p.off("touchstart.smoothscroll.amui",w),r=!1}function c(t){r&&(u||(u=t),h=Math.min(1,Math.max((t-u)/y,0)),d=Math.round(f+g*i(h)),g>0&&d>m&&(d=m),g<0&&d=0};var o=function(t,e){this.$element=n(t),this.options=n.extend({},o.DEFAULTS,{placeholder:t.getAttribute("placeholder")||o.DEFAULTS.placeholder},e),this.$originalOptions=this.$element.find("option"),this.multiple=t.multiple,this.$selector=null,this.initialized=!1,this.init()};o.DEFAULTS={btnWidth:null,btnSize:null,btnStyle:"default",dropUp:0,maxHeight:null,maxChecked:null,placeholder:"\u70b9\u51fb\u9009\u62e9...",selectedClass:"am-checked",disabledClass:"am-disabled",searchBox:!1,tpl:'

          \u8fd4\u56de

          <% if (searchBox) { %> <% } %>
            <% for (var i = 0; i < options.length; i++) { %> <% var option = options[i] %> <% if (option.header) { %>
          • <%= option.text %>
          • <% } else { %>
          • <%= option.text %>
          • <% } %> <% } %>
          ',listTpl:'<% for (var i = 0; i < options.length; i++) { %> <% var option = options[i] %> <% if (option.header) { %>
        4. <%= option.text %>
        5. <% } else { %>
        6. <%= option.text %>
        7. <% } %> <% } %>'},o.prototype.init=function(){var t=this,e=this.$element,i=this.options;e.hide();var o={id:s.utils.generateGUID("am-selected"),multiple:this.multiple,options:[],searchBox:i.searchBox,dropUp:i.dropUp,placeholder:i.placeholder};this.$selector=n(s.template(this.options.tpl,o)),this.$selector.css({width:this.options.btnWidth}),this.$list=this.$selector.find(".am-selected-list"),this.$searchField=this.$selector.find(".am-selected-search input"),this.$hint=this.$selector.find(".am-selected-hint");var a=this.$selector.find(".am-selected-btn"),r=[];i.btnSize&&r.push("am-btn-"+i.btnSize),i.btnStyle&&r.push("am-btn-"+i.btnStyle),a.addClass(r.join(" ")),this.$selector.dropdown({justify:a}),e[0].disabled&&this.disable(),i.maxHeight&&this.$selector.find(".am-selected-list").css({"max-height":i.maxHeight,"overflow-y":"scroll"});var l=[],c=e.attr("minchecked"),u=e.attr("maxchecked")||i.maxChecked;this.maxChecked=u||1/0,e[0].required&&l.push("\u5fc5\u9009"),(c||u)&&(c&&l.push("\u81f3\u5c11\u9009\u62e9 "+c+" \u9879"),u&&l.push("\u81f3\u591a\u9009\u62e9 "+u+" \u9879")),this.$hint.text(l.join("\uff0c")),this.renderOptions(),this.$element.after(this.$selector),this.dropdown=this.$selector.data("amui.dropdown"),this.$status=this.$selector.find(".am-selected-status"),setTimeout(function(){t.syncData(),t.initialized=!0},0),this.bindEvents()},o.prototype.renderOptions=function(){function t(t,e,s){if(""===e.value)return!0;var o="";e.disabled&&(o+=i.disabledClass),!e.disabled&&e.selected&&(o+=i.selectedClass),n.push({group:s,index:t,classNames:o,text:e.text,value:e.value})}var e=this.$element,i=this.options,n=[],o=e.find("optgroup");this.$originalOptions=this.$element.find("option"),this.multiple||null!==e.val()||this.$originalOptions.length&&(this.$originalOptions.get(0).selected=!0),o.length?o.each(function(e){n.push({header:!0,group:e+1,text:this.label}),o.eq(e).find("option").each(function(i,n){t(i,n,e)})}):this.$originalOptions.each(function(e,i){t(e,i,null)}),this.$list.html(s.template(i.listTpl,{options:n})),this.$shadowOptions=this.$list.find("> li").not(".am-selected-list-header")},o.prototype.setChecked=function(t){var e=this.options,i=n(t),s=i.hasClass(e.selectedClass);if(this.multiple){var o=this.$list.find("."+e.selectedClass).length;if(!s&&this.maxChecked<=o)return this.$element.trigger("checkedOverflow.selected.amui",{selected:this}),!1}else{if(this.dropdown.close(),s)return!1;this.$shadowOptions.not(i).removeClass(e.selectedClass)}i.toggleClass(e.selectedClass),this.syncData(t)},o.prototype.syncData=function(t){var e=this,i=this.options,s=[],o=n([]);if(this.$shadowOptions.filter("."+i.selectedClass).each(function(){var i=n(this);s.push(i.find(".am-selected-text").text()),t||(o=o.add(e.$originalOptions.filter('[value="'+i.data("value")+'"]').prop("selected",!0)))}),t){var a=n(t);this.$originalOptions.filter('[value="'+a.data("value")+'"]').prop("selected",a.hasClass(i.selectedClass))}else this.$originalOptions.not(o).prop("selected",!1);this.$element.val()||(s=[i.placeholder]),this.$status.text(s.join(", ")),this.initialized&&this.$element.trigger("change")},o.prototype.bindEvents=function(){var t=this,e="am-selected-list-header",i=s.utils.debounce(function(i){t.$shadowOptions.not("."+e).hide().filter(':containsNC("'+i.target.value+'")').show()},100);this.$list.on("click","> li",function(i){var s=n(this);!s.hasClass(t.options.disabledClass)&&!s.hasClass(e)&&t.setChecked(this)}),this.$searchField.on("keyup.selected.amui",i),this.$selector.on("closed.dropdown.amui",function(){t.$searchField.val(""),t.$shadowOptions.css({display:""})}),this.$element.on("validated.field.validator.amui",function(e){if(e.validity){var i=e.validity.valid,n="am-invalid";t.$selector[(i?"remove":"add")+"Class"](n)}}),s.support.mutationobserver&&(this.observer=new s.support.mutationobserver(function(){t.$element.trigger("changed.selected.amui")}),this.observer.observe(this.$element[0],{childList:!0,subtree:!0,characterData:!0})),this.$element.on("changed.selected.amui",function(){t.renderOptions(),t.syncData()})},o.prototype.select=function(t){var e;e="number"==typeof t?this.$list.find("> li").not(".am-selected-list-header").eq(t):"string"==typeof t?this.$list.find(t):n(t),e.trigger("click")},o.prototype.enable=function(){this.$element.prop("disable",!1),this.$selector.dropdown("enable")},o.prototype.disable=function(){this.$element.prop("disable",!0),this.$selector.dropdown("disable")},o.prototype.destroy=function(){this.$element.removeData("amui.selected").show(),this.$selector.remove()},s.plugin("selected",o),s.ready(function(t){n("[data-am-selected]",t).selected()}),t.exports=o},function(t,e,i){"use strict";i(15);var n=i(1),s=i(2),o=i(26),a=document,r=n(a),l=function(t){this.options=n.extend({},l.DEFAULTS,t||{}),this.$element=null,this.$wechatQr=null,this.pics=null,this.inited=!1,this.active=!1};l.DEFAULTS={sns:["weibo","qq","qzone","tqq","wechat","renren"],title:"\u5206\u4eab\u5230",cancel:"\u53d6\u6d88",closeOnShare:!0,id:s.utils.generateGUID("am-share"),desc:"Hi\uff0c\u5b64\u591c\u89c2\u5929\u8c61\uff0c\u53d1\u73b0\u4e00\u4e2a\u4e0d\u9519\u7684\u897f\u897f\uff0c\u5206\u4eab\u4e00\u4e0b\u4e0b ;-)",via:"Amaze UI",tpl:''},l.SNS={weibo:{title:"\u65b0\u6d6a\u5fae\u535a",url:"http://service.weibo.com/share/share.php",width:620,height:450,icon:"weibo"},qq:{title:"QQ \u597d\u53cb",url:"http://connect.qq.com/widget/shareqq/index.html",icon:"qq"},qzone:{title:"QQ \u7a7a\u95f4",url:"http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey",icon:"star"},tqq:{title:"\u817e\u8baf\u5fae\u535a",url:"http://v.t.qq.com/share/share.php",icon:"tencent-weibo"},wechat:{title:"\u5fae\u4fe1",url:"[qrcode]",icon:"wechat"},renren:{title:"\u4eba\u4eba\u7f51",url:"http://widget.renren.com/dialog/share",icon:"renren"},douban:{title:"\u8c46\u74e3",url:"http://www.douban.com/recommend/",icon:"share-alt"},mail:{title:"\u90ae\u4ef6\u5206\u4eab",url:"mailto:",icon:"envelope-o"},sms:{title:"\u77ed\u4fe1\u5206\u4eab",url:"sms:",icon:"comment"}},l.prototype.render=function(){var t=this.options,e=[],i=encodeURIComponent(a.title),o=encodeURIComponent(a.location),r="?body="+i+o;return t.sns.forEach(function(n,s){if(l.SNS[n]){var a,c=l.SNS[n];c.id=n,a="mail"===n?r+"&subject="+t.desc:"sms"===n?r:"?url="+o+"&title="+i,c.shareUrl=c.url+a,e.push(c)}}),s.template(t.tpl,n.extend({},t,{sns:e}))},l.prototype.init=function(){if(!this.inited){var t=this,e="[data-am-share-to]";r.ready(n.proxy(function(){n("body").append(this.render()),this.$element=n("#"+this.options.id),this.$element.find("[data-am-share-close]").on("click.share.amui",function(){t.close()})},this)),r.on("click.share.amui",e,n.proxy(function(t){var i=n(t.target),s=i.is(e)&&i||i.parent(e),o=s.attr("data-am-share-to");"mail"!==o&&"sms"!==o&&(t.preventDefault(),this.shareTo(o,this.setData(o))),this.close()},this)),this.inited=!0}},l.prototype.open=function(){!this.inited&&this.init(),this.$element&&this.$element.modal("open"),this.$element.trigger("open.share.amui"),this.active=!0},l.prototype.close=function(){this.$element&&this.$element.modal("close"),this.$element.trigger("close.share.amui"),this.active=!1},l.prototype.toggle=function(){this.active?this.close():this.open()},l.prototype.setData=function(t){if(t){var e={url:a.location,title:a.title},i=this.options.desc,n=this.pics||[],s=/^(qzone|qq|tqq)$/;if(s.test(t)&&!n.length){for(var o=a.images,r=0;r
          ');e.attr("id",t);var i=new o({render:"canvas",correctLevel:0,text:a.location.href,width:180,height:180,background:"#fff",foreground:"#000"});e.find(".am-share-wx-qr").html(i),e.appendTo(n("body")),this.$wechatQr=n("#"+t)}this.$wechatQr.modal("open")};var c=new l;r.on("click.share.amui.data-api",'[data-am-toggle="share"]',function(t){t.preventDefault(),c.toggle()}),t.exports=s.share=c},function(t,e,i){function n(t){return t<128?[t]:t<2048?(c0=192+(t>>6),c1=128+(63&t),[c0,c1]):(c0=224+(t>>12),c1=128+(t>>6&63),c2=128+(63&t),[c0,c1,c2])}function s(t){for(var e=[],i=0;i>6),c1=128+(63&t),[c0,c1]):(c0=224+(t>>12),c1=128+(t>>6&63),c2=128+(63&t),[c0,c1,c2])}function s(t){for(var e=[],i=0;i');var i=-1,n=-1,s=-1,o=-1;i=s=Math.floor(this.options.width/t.getModuleCount()),n=o=Math.floor(this.options.height/t.getModuleCount()),s<=0&&(i=t.getModuleCount()<80?2:1),o<=0&&(n=t.getModuleCount()<80?2:1),foreTd='',backTd='',l=t.getModuleCount();for(var a=0;a');for(var r=0;r")}e.push("");var c=document.createElement("span");return c.innerHTML=e.join(""),c.firstChild},d.prototype.createSVG=function(t){for(var e,i,n,s,o=t.getModuleCount(),a=this.options.height/this.options.width,r='',l="',h=' style="stroke-width:0.5;stroke:'+this.options.background+";fill:"+this.options.background+';">',d=0;d=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var i=-1;i<=7;i++)if(!(t+i<=-1||this.moduleCount<=t+i))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(0<=i&&i<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==i||6==i)||2<=i&&i<=4&&2<=n&&n<=4?this.modules[t+i][e+n]=!0:this.modules[t+i][e+n]=!1)},createQrcode:function(){for(var t=0,e=0,i=null,n=0;n<8;n++){this.makeImpl(n);var s=f.getLostPoint(this);(0==n||t>s)&&(t=s,e=n,i=this.modules)}this.modules=i,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t>i&1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3]=n,this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=n}},setupTypeInfo:function(t,e){for(var i=p[this.errorCorrectLevel]<<3|e,n=f.getBCHTypeInfo(i),s=0;s<15;s++){var o=!t&&1==(n>>s&1);s<6?this.modules[s][8]=o:s<8?this.modules[s+1][8]=o:this.modules[this.moduleCount-15+s][8]=o;var o=!t&&1==(n>>s&1);s<8?this.modules[8][this.moduleCount-s-1]=o:s<9?this.modules[8][15-s-1+1]=o:this.modules[8][15-s-1]=o}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new r,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var i=0,n=this.utf8bytes.length;i=8*this.totalDataCount)break;if(t.put(o.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(o.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,i=0,n=0,s=this.rsBlock.length/3,o=new Array,r=0;r=0?b.get(T):0}}for(var x=new Array(this.totalDataCount),C=0,r=0;r0;a-=2)for(6==a&&a--;;){for(var r=0;r<2;r++)if(null==this.modules[n][a-r]){var l=!1;o>>s&1));var c=f.getMask(e,n,a-r);c&&(l=!l),this.modules[n][a-r]=l,s--,s==-1&&(o++,s=7)}if(n+=i,n<0||this.moduleCount<=n){n-=i,i=-i;break}}}},o.PAD0=236,o.PAD1=17;for(var p=[1,0,3,2],m={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},f={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;f.getBCHDigit(e)-f.getBCHDigit(f.G15)>=0;)e^=f.G15<=0;)e^=f.G18<>>=1;return e},getPatternPosition:function(t){return f.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,i){switch(t){case m.PATTERN000:return(e+i)%2==0;case m.PATTERN001:return e%2==0;case m.PATTERN010:return i%3==0;case m.PATTERN011:return(e+i)%3==0;case m.PATTERN100:return(Math.floor(e/2)+Math.floor(i/3))%2==0;case m.PATTERN101:return e*i%2+e*i%3==0;case m.PATTERN110:return(e*i%2+e*i%3)%2==0;case m.PATTERN111:return(e*i%3+(e+i)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new a([1],0),i=0;i3&&t.modules[s][r-1]&&t.modules[s][r-2]&&t.modules[s][r-3]&&t.modules[s][r-4]&&(i+=40)),s=5&&(i+=3+o-5),o=1),l&&n++}for(var r=0;r3&&t.modules[s-1][r]&&t.modules[s-2][r]&&t.modules[s-3][r]&&t.modules[s-4][r]&&(i+=40)), -a^l?o++:(a=l,o>=5&&(i+=3+o-5),o=1)}var u=Math.abs(100*n/e/e-50)/5;return i+=10*u}},v={glog:function(t){if(t<1)throw new Error("glog("+t+")");return v.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return v.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;g<8;g++)v.EXP_TABLE[g]=1<=i;){for(var o=v.glog(n[0])-v.glog(t.get(0)),s=0;s9?2:1;if(this.utf8bytes.length+r>>7-t%8&1},put:function(t,e){for(var i=0;i>>e-i-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},o.prototype={constructor:o,getModuleCount:function(){return this.moduleCount},make:function(){this.getRightType(),this.dataCache=this.createData(),this.createQrcode()},makeImpl:function(t){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var e=0;e=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var i=-1;i<=7;i++)if(!(t+i<=-1||this.moduleCount<=t+i))for(var n=-1;n<=7;n++)e+n<=-1||this.moduleCount<=e+n||(0<=i&&i<=6&&(0==n||6==n)||0<=n&&n<=6&&(0==i||6==i)||2<=i&&i<=4&&2<=n&&n<=4?this.modules[t+i][e+n]=!0:this.modules[t+i][e+n]=!1)},createQrcode:function(){for(var t=0,e=0,i=null,n=0;n<8;n++){this.makeImpl(n);var s=f.getLostPoint(this);(0==n||t>s)&&(t=s,e=n,i=this.modules)}this.modules=i,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t>i&1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3]=n,this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=n}},setupTypeInfo:function(t,e){for(var i=p[this.errorCorrectLevel]<<3|e,n=f.getBCHTypeInfo(i),s=0;s<15;s++){var o=!t&&1==(n>>s&1);s<6?this.modules[s][8]=o:s<8?this.modules[s+1][8]=o:this.modules[this.moduleCount-15+s][8]=o;var o=!t&&1==(n>>s&1);s<8?this.modules[8][this.moduleCount-s-1]=o:s<9?this.modules[8][15-s-1+1]=o:this.modules[8][15-s-1]=o}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new r,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var i=0,n=this.utf8bytes.length;i=8*this.totalDataCount)break;if(t.put(o.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(o.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,i=0,n=0,s=this.rsBlock.length/3,o=new Array,r=0;r=0?b.get(T):0}}for(var x=new Array(this.totalDataCount),C=0,r=0;r0;a-=2)for(6==a&&a--;;){for(var r=0;r<2;r++)if(null==this.modules[n][a-r]){var l=!1;o>>s&1));var c=f.getMask(e,n,a-r);c&&(l=!l),this.modules[n][a-r]=l,s--,s==-1&&(o++,s=7)}if(n+=i,n<0||this.moduleCount<=n){n-=i,i=-i;break}}}},o.PAD0=236,o.PAD1=17;for(var p=[1,0,3,2],m={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},f={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;f.getBCHDigit(e)-f.getBCHDigit(f.G15)>=0;)e^=f.G15<=0;)e^=f.G18<>>=1;return e},getPatternPosition:function(t){return f.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,i){switch(t){case m.PATTERN000:return(e+i)%2==0;case m.PATTERN001:return e%2==0;case m.PATTERN010:return i%3==0;case m.PATTERN011:return(e+i)%3==0;case m.PATTERN100:return(Math.floor(e/2)+Math.floor(i/3))%2==0;case m.PATTERN101:return e*i%2+e*i%3==0;case m.PATTERN110:return(e*i%2+e*i%3)%2==0;case m.PATTERN111:return(e*i%3+(e+i)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new a([1],0),i=0;i3&&t.modules[s][r-1]&&t.modules[s][r-2]&&t.modules[s][r-3]&&t.modules[s][r-4]&&(i+=40)),s=5&&(i+=3+o-5),o=1),l&&n++}for(var r=0;r3&&t.modules[s-1][r]&&t.modules[s-2][r]&&t.modules[s-3][r]&&t.modules[s-4][r]&&(i+=40)),a^l?o++:(a=l,o>=5&&(i+=3+o-5),o=1)}var u=Math.abs(100*n/e/e-50)/5;return i+=10*u}},v={glog:function(t){if(t<1)throw new Error("glog("+t+")");return v.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return v.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;g<8;g++)v.EXP_TABLE[g]=1<=i;){for(var o=v.glog(n[0])-v.glog(t.get(0)),s=0;s9?2:1;if(this.utf8bytes.length+r>>7-t%8&1},put:function(t,e){for(var i=0;i>>e-i-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},c.fn.qrcode=function(t){return this.each(function(){c(this).append(new d(t))})},t.exports=u.qrcode=d},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){var i=this;this.options=n.extend({},o.DEFAULTS,e),this.$element=n(t),this.sticked=null,this.inited=null,this.$holder=void 0,this.$window=n(window).on("scroll.sticky.amui",s.utils.debounce(n.proxy(this.checkPosition,this),10)).on("resize.sticky.amui orientationchange.sticky.amui",s.utils.debounce(function(){i.reset(!0,function(){i.checkPosition()})},50)).on("load.sticky.amui",n.proxy(this.checkPosition,this)),this.offset=this.$element.offset(),this.init()};o.DEFAULTS={top:0,bottom:0,animation:"",className:{sticky:"am-sticky",resetting:"am-sticky-resetting",stickyBtm:"am-sticky-bottom",animationRev:"am-animation-reverse"}},o.prototype.init=function(){var t=this.check();if(!t)return!1;var e=this.$element,i="";n.each(e.css(["marginTop","marginRight","marginBottom","marginLeft"]),function(t,e){return i+=" "+e});var s=n('
          ').css({height:"absolute"!==e.css("position")?e.outerHeight():"","float":"none"!=e.css("float")?e.css("float"):"",margin:i});return this.$holder=e.css("margin",0).wrap(s).parent(),this.inited=1,!0},o.prototype.reset=function(t,e){var i=this.options,n=this.$element,o=i.animation?" am-animation-"+i.animation:"",a=function(){n.css({position:"",top:"",width:"",left:"",margin:0}),n.removeClass([o,i.className.animationRev,i.className.sticky,i.className.resetting].join(" ")),this.animating=!1,this.sticked=!1,this.offset=n.offset(),e&&e()}.bind(this);n.addClass(i.className.resetting),!t&&i.animation&&s.support.animation?(this.animating=!0,n.removeClass(o).one(s.support.animation.end,function(){a()}).width(),n.addClass(o+" "+i.className.animationRev)):a()},o.prototype.check=function(){if(!this.$element.is(":visible"))return!1;var t=this.options.media;if(t)switch(typeof t){case"number":if(window.innerWidththis.$holder.offset().top;!this.sticked&&l?o.addClass(r):this.sticked&&!l&&this.reset(),this.$holder.css({height:o.is(":visible")&&"absolute"!==o.css("position")?o.outerHeight():""}),l&&o.css({top:n,left:this.$holder.offset().left,width:this.$holder.width()}),this.sticked=l},s.plugin("sticky",o),n(window).on("load",function(){n("[data-am-sticky]").sticky()}),t.exports=o},function(t,e,i){"use strict";function n(t){var e,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var n=s(this),a=n.is(".am-tabs")&&n||n.closest(".am-tabs"),r=a.data("amui.tabs"),l=s.extend({},o.utils.parseOptions(n.data("amTabs")),s.isPlainObject(t)&&t);r||a.data("amui.tabs",r=new c(a[0],l)),"string"==typeof t&&("open"===t&&n.is(".am-tabs-nav a")?r.open(n):e="function"==typeof r[t]?r[t].apply(r,i):r[t])}),void 0===e?this:e}var s=i(1),o=i(2),a=i(3),r=o.support.transition,l=o.support.animation,c=function(t,e){this.$element=s(t),this.options=s.extend({},c.DEFAULTS,e||{}),this.transitioning=this.activeIndex=null,this.refresh(),this.init()};c.DEFAULTS={selector:{nav:"> .am-tabs-nav",content:"> .am-tabs-bd",panel:"> .am-tab-panel"},activeClass:"am-active"},c.prototype.refresh=function(){var t=this.options.selector;this.$tabNav=this.$element.find(t.nav),this.$navs=this.$tabNav.find("a"),this.$content=this.$element.find(t.content),this.$tabPanels=this.$content.find(t.panel);var e=this.$tabNav.find("> ."+this.options.activeClass);1!==e.length?this.open(0):this.activeIndex=this.$navs.index(e.children("a"))},c.prototype.init=function(){var t=this,e=this.options;if(this.$element.on("click.tabs.amui",e.selector.nav+" a",function(e){e.preventDefault(),t.open(s(this))}),!e.noSwipe){if(!this.$content.length)return this;var i=new a.Manager(this.$content[0]),n=new a.Swipe({direction:a.DIRECTION_HORIZONTAL});i.add(n),i.on("swipeleft",o.utils.debounce(function(e){e.preventDefault(),t.goTo("next")},100)),i.on("swiperight",o.utils.debounce(function(e){e.preventDefault(),t.goTo("prev")},100)),this._hammer=i}},c.prototype.open=function(t){var e=this.options.activeClass,i="number"==typeof t?t:this.$navs.index(s(t));if(t="number"==typeof t?this.$navs.eq(i):s(t),t&&t.length&&!this.transitioning&&!t.parent("li").hasClass(e)){var n=this.$tabNav,o=t.attr("href"),a=/^#.+$/,r=a.test(o)&&this.$content.find(o)||this.$tabPanels.eq(i),l=n.find("."+e+" a")[0],c=s.Event("open.tabs.amui",{relatedTarget:l});t.trigger(c),c.isDefaultPrevented()||(this.activate(t.closest("li"),n),this.activate(r,this.$content,function(){t.trigger({type:"opened.tabs.amui",relatedTarget:l})}),this.activeIndex=i)}},c.prototype.activate=function(t,e,i){this.transitioning=!0;var n=this.options.activeClass,o=e.find("> ."+n),a=i&&r&&!!o.length;o.removeClass(n+" am-in"),t.addClass(n),a?(t.redraw(),t.addClass("am-in")):t.removeClass("am-fade");var l=s.proxy(function(){i&&i(),this.transitioning=!1},this);a&&!this.$content.is(".am-tabs-bd-ofv")?o.one(r.end,l):l()},c.prototype.goTo=function(t){var e=this.activeIndex,i="next"===t,n=i?"am-animation-right-spring":"am-animation-left-spring";if(i&&e+1>=this.$navs.length||!i&&0===e){var s=this.$tabPanels.eq(e);l&&s.addClass(n).on(l.end,function(){s.removeClass(n)})}else this.open(i?e+1:e-1)},c.prototype.destroy=function(){this.$element.off(".tabs.amui"),a.off(this.$content[0],"swipeleft swiperight"),this._hammer&&this._hammer.destroy(),s.removeData(this.$element,"amui.tabs")},s.fn.tabs=n,o.ready(function(t){s("[data-am-tabs]",t).tabs()}),s(document).on("click.tabs.amui.data-api","[data-am-tabs] .am-tabs-nav a",function(t){t.preventDefault(),n.call(s(this),"open")}),t.exports=o.tabs=c},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){this.options=n.extend({},o.DEFAULTS,e),this.$element=n(t),this.init()};o.DEFAULTS={checkboxClass:"am-ucheck-checkbox",radioClass:"am-ucheck-radio",checkboxTpl:'',radioTpl:''},o.prototype.init=function(){var t=this.$element,e=t[0],i=this.options;"checkbox"===e.type?t.addClass(i.checkboxClass).after(i.checkboxTpl):"radio"===e.type&&t.addClass(i.radioClass).after(i.radioTpl)},o.prototype.check=function(){this.$element.prop("checked",!0).trigger("change.ucheck.amui").trigger("checked.ucheck.amui")},o.prototype.uncheck=function(){this.$element.prop("checked",!1).trigger("change").trigger("unchecked.ucheck.amui")},o.prototype.toggle=function(){this.$element.prop("checked",function(t,e){return!e}).trigger("change.ucheck.amui").trigger("toggled.ucheck.amui")},o.prototype.disable=function(){this.$element.prop("disabled",!0).trigger("change.ucheck.amui").trigger("disabled.ucheck.amui")},o.prototype.enable=function(){this.$element.prop("disabled",!1),this.$element.trigger("change.ucheck.amui").trigger("enabled.ucheck.amui")},o.prototype.destroy=function(){this.$element.removeData("amui.ucheck").removeClass(this.options.checkboxClass+" "+this.options.radioClass).next(".am-ucheck-icons").remove().end().trigger("destroyed.ucheck.amui")},s.plugin("uCheck",o,{after:function(){s.support.touch&&this.parent().hover(function(){n(this).addClass("am-nohover")},function(){n(this).removeClass("am-nohover")})}}),s.ready(function(t){n("[data-am-ucheck]",t).uCheck()}),t.exports=o},function(t,e,i){"use strict";var n=i(1),s=i(2),o=function(t,e){this.options=n.extend({},o.DEFAULTS,e),this.options.patterns=n.extend({},o.patterns,this.options.patterns);var i=this.options.locales;!o.validationMessages[i]&&(this.options.locales="zh_CN"),this.$element=n(t),this.init()};o.DEFAULTS={debug:!1,locales:"zh_CN",H5validation:!1,H5inputType:["email","url","number"],patterns:{},patternClassPrefix:"js-pattern-",activeClass:"am-active",inValidClass:"am-field-error",validClass:"am-field-valid",validateOnSubmit:!0,alwaysRevalidate:!1,allFields:":input:not(:submit, :button, :disabled, .am-novalidate)",ignore:":hidden:not([data-am-selected], .am-validate)",customEvents:"validate",keyboardFields:":input:not(:submit, :button, :disabled, .am-novalidate)",keyboardEvents:"focusout, change",activeKeyup:!1,textareaMaxlenthKeyup:!0,pointerFields:'input[type="range"]:not(:disabled, .am-novalidate), input[type="radio"]:not(:disabled, .am-novalidate), input[type="checkbox"]:not(:disabled, .am-novalidate), select:not(:disabled, .am-novalidate), option:not(:disabled, .am-novalidate)',pointerEvents:"click",onValid:function(t){},onInValid:function(t){},markValid:function(t){var e=this.options,i=n(t.field),s=i.closest(".am-form-group");i.addClass(e.validClass).removeClass(e.inValidClass),s.addClass("am-form-success").removeClass("am-form-error"),e.onValid.call(this,t)},markInValid:function(t){var e=this.options,i=n(t.field),s=i.closest(".am-form-group");i.addClass(e.inValidClass+" "+e.activeClass).removeClass(e.validClass),s.addClass("am-form-error").removeClass("am-form-success"),e.onInValid.call(this,t)},validate:function(t){},submit:null},o.VERSION="2.7.2",o.patterns={email:/^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/,url:/^(https?|ftp):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,number:/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/,dateISO:/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,integer:/^-?\d+$/},o.validationMessages={zh_CN:{valueMissing:"\u8bf7\u586b\u5199\uff08\u9009\u62e9\uff09\u6b64\u5b57\u6bb5",customError:{tooShort:"\u81f3\u5c11\u586b\u5199 %s \u4e2a\u5b57\u7b26",checkedOverflow:"\u81f3\u591a\u9009\u62e9 %s \u9879",checkedUnderflow:"\u81f3\u5c11\u9009\u62e9 %s \u9879"},patternMismatch:"\u8bf7\u6309\u7167\u8981\u6c42\u7684\u683c\u5f0f\u586b\u5199",rangeOverflow:"\u8bf7\u586b\u5199\u5c0f\u4e8e\u7b49\u4e8e %s \u7684\u503c",rangeUnderflow:"\u8bf7\u586b\u5199\u5927\u4e8e\u7b49\u4e8e %s \u7684\u503c",stepMismatch:"",tooLong:"\u81f3\u591a\u586b\u5199 %s \u4e2a\u5b57\u7b26",typeMismatch:"\u8bf7\u6309\u7167\u8981\u6c42\u7684\u7c7b\u578b\u586b\u5199"}},o.ERROR_MAP={tooShort:"minlength",checkedOverflow:"maxchecked",checkedUnderflow:"minchecked",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength"},o.prototype.init=function(){function t(t){var e=t.toString();return e.substring(1,e.length-1)}function e(t,e,a){var r=e.split(","),l=function(t){i.validate(this)};a&&(l=s.utils.debounce(l,a)),n.each(r,function(e,i){o.on(i+".validator.amui",t,l)})}var i=this,o=this.$element,a=this.options;return(!a.H5validation||!s.support.formValidation)&&(o.attr("novalidate","novalidate"),n.each(a.H5inputType,function(e,i){var n=o.find("input[type="+i+"]");n.attr("pattern")||n.is("[class*="+a.patternClassPrefix+"]")||n.attr("pattern",t(a.patterns[i]))}),n.each(a.patterns,function(e,i){var n=o.find("."+a.patternClassPrefix+e);!n.attr("pattern")&&n.attr("pattern",t(i))}),o.on("submit.validator.amui",function(t){if("function"==typeof a.submit)return a.submit.call(i,t);if(a.validateOnSubmit){var e=i.isFormValid();return"boolean"===n.type(e)?e:!!o.data("amui.checked")||(n.when(e).then(function(){o.data("amui.checked",!0).submit()},function(){o.data("amui.checked",!1).find("."+a.inValidClass).eq(0).focus()}),!1)}}),e(":input",a.customEvents),e(a.keyboardFields,a.keyboardEvents),e(a.pointerFields,a.pointerEvents),a.textareaMaxlenthKeyup&&e("textarea[maxlength]","keyup",50),void(a.activeKeyup&&e(".am-active","keyup",50)))},o.prototype.isValid=function(t){var e=n(t),i=this.options;return(void 0===e.data("validity")||i.alwaysRevalidate)&&this.validate(t),e.data("validity")&&e.data("validity").valid},o.prototype.validate=function(t){var e=this,i=this.$element,s=this.options,o=n(t),a=o.data("equalTo");a&&o.attr("pattern","^"+i.find(a).val()+"$");var r=o.attr("pattern")||!1,l=new RegExp(r),c=null,u=null,h=o.is("[type=checkbox]")?(u=i.find('input[name="'+t.name+'"]')).filter(":checked").length:o.is("[type=radio]")?(c=this.$element.find('input[name="'+t.name+'"]')).filter(":checked").length>0:o.val();o=u&&u.length?u.first():o;var d=void 0!==o.attr("required")&&"false"!==o.attr("required"),p=parseInt(o.attr("maxlength"),10),m=parseInt(o.attr("minlength"),10),f=Number(o.attr("min")),v=Number(o.attr("max")),g=this.createValidity({field:o[0],valid:!0});if(s.debug&&window.console&&(console.log("Validate: value -> ["+h+", regex -> ["+l+"], required -> "+d),console.log("Regex test: "+l.test(h)+", Pattern: "+r)),!isNaN(p)&&h.length>p&&(g.valid=!1,g.tooLong=!0),!isNaN(m)&&h.lengthv&&(g.valid=!1,g.rangeOverflow=!0),d&&!h)g.valid=!1,g.valueMissing=!0;else if((u||o.is('select[multiple="multiple"]'))&&h){h=u?h:h.length;var y=parseInt(o.attr("minchecked"),10),w=parseInt(o.attr("maxchecked"),10);!isNaN(y)&&hw&&(g.valid=!1,g.customError="checkedOverflow")}else r&&!l.test(h)&&h&&(g.valid=!1,g.patternMismatch=!0);var b,T=function(t){this.markField(t);var i=n.Event("validated.field.validator.amui");i.validity=t,o.trigger(i).data("validity",t);var s=c||u;return s&&s.not(o).data("validity",t).each(function(){t.field=this,e.markField(t)}),t};if("function"==typeof s.validate&&(b=s.validate.call(this,g)),b){var x=new n.Deferred;return o.data("amui.dfdValidity",x.promise()),n.when(b).always(function(t){x[t.valid?"resolve":"reject"](t),T.call(e,t)})}T.call(this,g)},o.prototype.markField=function(t){var e=this.options,i="mark"+(t.valid?"":"In")+"Valid";e[i]&&e[i].call(this,t)},o.prototype.validateForm=function(){var t=this,e=this.$element,i=this.options,s=e.find(i.allFields).not(i.ignore),o=[],a=!0,r=[],l=n([]),c=[],u=!1;e.trigger("validate.form.validator.amui");var h=s.filter(function(t){var e;if("INPUT"===this.tagName&&"radio"===this.type){if(e=this.name,o[e]===!0)return!1;o[e]=!0; -}return!0});h.each(function(){var i=n(this),s=t.isValid(this),o=i.data("validity");a=!!s&&a,r.push(o),s||(l=l.add(n(this),e));var h=i.data("amui.dfdValidity");if(h)c.push(h),u=!0;else{var d=new n.Deferred;c.push(d.promise()),d[s?"resolve":"reject"](o)}});var d={valid:a,$invalidFields:l,validity:r,promises:c,async:u};return e.trigger("validated.form.validator.amui",d),d},o.prototype.isFormValid=function(){var t=this,e=this.validateForm(),i=function(e){t.$element.trigger(e+".validator.amui")};if(e.async){var s=new n.Deferred;return n.when.apply(null,e.promises).then(function(){s.resolve(),i("valid")},function(){s.reject(),i("invalid")}),s.promise()}if(!e.valid){var o=e.$invalidFields.first();return o.is("[data-am-selected]")&&(o=o.next(".am-selected").find(".am-selected-btn")),o.focus(),i("invalid"),!1}return i("valid"),!0},o.prototype.createValidity=function(t){return n.extend({customError:t.customError||!1,patternMismatch:t.patternMismatch||!1,rangeOverflow:t.rangeOverflow||!1,rangeUnderflow:t.rangeUnderflow||!1,stepMismatch:t.stepMismatch||!1,tooLong:t.tooLong||!1,typeMismatch:t.typeMismatch||!1,valid:t.valid||!0,valueMissing:t.valueMissing||!1},t)},o.prototype.getValidationMessage=function(t){var e,i,s=o.validationMessages[this.options.locales],a="%s",r=n(t.field);return(r.is('[type="checkbox"]')||r.is('[type="radio"]'))&&(r=this.$element.find("[name="+r.attr("name")+"]").first()),n.each(t,function(t,i){return"field"===t||"valid"===t?t:"customError"===t&&i?(e=i,s=s.customError,!1):i===!0?(e=t,!1):void 0}),i=s[e]||void 0,i&&o.ERROR_MAP[e]&&(i=i.replace(a,r.attr(o.ERROR_MAP[e])||"\u89c4\u5b9a\u7684")),i},o.prototype.removeMark=function(){this.$element.find(".am-form-success, .am-form-error, ."+this.options.inValidClass+", ."+this.options.validClass).removeClass(["am-form-success","am-form-error",this.options.inValidClass,this.options.validClass].join(" "))},o.prototype.destroy=function(){this.removeMark(),this.$element.removeData("amui.validator amui.checked").off(".validator.amui").find(this.options.allFields).removeData("validity amui.dfdValidity")},s.plugin("validator",o),s.ready(function(t){n("[data-am-validator]",t).validator()}),t.exports=o},function(t,e,i){"use strict";var n=i(2),s={get:function(t){var e,i=encodeURIComponent(t)+"=",n=document.cookie.indexOf(i),s=null;return n>-1&&(e=document.cookie.indexOf(";",n),e==-1&&(e=document.cookie.length),s=decodeURIComponent(document.cookie.substring(n+i.length,e))),s},set:function(t,e,i,n,s,o){var a=encodeURIComponent(t)+"="+encodeURIComponent(e);i instanceof Date&&(a+="; expires="+i.toUTCString()),n&&(a+="; path="+n),s&&(a+="; domain="+s),o&&(a+="; secure"),document.cookie=a},unset:function(t,e,i,n){this.set(t,"",new Date(0),e,i,n)}};n.utils=n.utils||{},t.exports=n.utils.cookie=s},function(t,e,i){"use strict";var n=i(2),s=function(){var t="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,e=function(){for(var t,e,i=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],n=0,s=i.length,o={};n",{async:!0,type:"text/javascript",src:i,charset:"utf-8"});s("body").append(n)}}var s=i(1),o=i(2);s(window).on("load",n),t.exports=o.duoshuo={VERSION:"2.0.1",init:n}},function(t,e,i){"use strict";function n(){s(".am-figure").each(function(t,e){var i,n=o.utils.parseOptions(s(e).attr("data-am-figure")),a=s(e);if(n.pureview)if("auto"===n.pureview){var r=s.isImgZoomAble(a.find("img")[0]);r&&a.pureview()}else a.addClass("am-figure-zoomable").pureview();i=a.data("amui.pureview"),i&&a.on("click",":not(img)",function(){i.open(0)})})}var s=i(1),o=i(2);i(20),s.isImgZoomAble=function(t){var e=new Image;e.src=t.src;var i=s(t).width()50?"add":"remove")+"Class"]("am-active")}var e=s('[data-am-widget="gotop"]'),i=e.filter(".am-gotop-fixed"),n=s(window);e.data("init")||(e.find("a").on("click",function(t){t.preventDefault(),n.smoothScroll()}),t(),n.on("scroll.gotop.amui",o.utils.debounce(t,100)),e.data("init",!0))}var s=i(1),o=i(2);i(23),s(n),t.exports=o.gotop={VERSION:"4.0.2",init:n}},function(t,e,i){"use strict";function n(){s('[data-am-widget="header"]').each(function(){if(s(this).hasClass("am-header-fixed"))return s("body").addClass("am-with-fixed-header"),!1})}var s=i(1),o=i(2);s(n),t.exports=o.header={VERSION:"2.0.0",init:n}},function(t,e,i){"use strict";var n=i(2);t.exports=n.intro={VERSION:"4.0.2",init:function(){}}},function(t,e,i){"use strict";var n=i(2);t.exports=n.listNews={VERSION:"4.0.0",init:function(){}}},function(t,e,i){function n(t){var e=o(" - - - - - - - -
          - -
          - - - - - -
          - -
          -
          -
          -
          -
          - 选择主题 -
          -
          - - -
          -
          -
          - - - - -
          -
          -
          -
          -
          部件首页 Amaze UI
          -

          Amaze UI 含近 20 个 CSS 组件、20 余 JS 组件,更有多个包含不同主题的 Web 组件。

          -
          -
          - -
          -
          -
          - -
          -
          -
          -
          -
          -
          月度财务收支计划
          -
          - -
          -
          -
          -
          -
          - ¥61746.45 - -
          -
          -
          -
          - +¥30420.56 - -
          -
          - 8月份收入 -
          -
          -
          -
          - -
          -
          -
          -
          - 本季度利润 -
          -
          -
          - ¥27,294 -
          -
          - 本季度比去年多收入 2593元 人民币 -
          - -
          -
          -
          -
          -
          -
          - 本季度利润 -
          -
          -
          - ¥27,294 -
          -
          - 本季度比去年多收入 2593元 人民币 -
          - -
          -
          -
          -
          - -
          -
          -
          -
          -
          月度财务收支计划
          -
          - -
          -
          -
          -
          -
          -
          - -
          -
          -
          -
          专用服务器负载
          -
          - -
          -
          -
          -
          CPU Load 28% / 100%
          -
          -
          -
          -
          CPU Load 28% / 100%
          -
          -
          -
          -
          CPU Load 28% / 100%
          -
          -
          -
          -
          -
          -
          -
          - - -
          -
          -
          -
          - 禁言小张 -
          -
          - 月度最佳员工 -
          - -
          - 禁言小张在 - 30天内 禁言了 - 200多人。 -
          -
          -
          - -
          -
          -
          -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          文章标题作者时间操作
          新加坡大数据初创公司 Latize 获 150 万美元风险融资张鹏飞2016-09-26 - -
          自拍的“政治角色”:观众背对希拉里自拍合影表示“支持”天纵之人2016-09-26 - -
          关于创新管理,我想和你当面聊聊。王宽师2016-09-26 - -
          究竟是趋势带动投资,还是投资引领趋势?着迷2016-09-26 - -
          Docker领域再添一员,网易云发布“蜂巢”,加入云计算之争醉里挑灯看键2016-09-26 - -
          -
          -
          -
          -
          -
          -
          -
          -
          -
          - - - - - - \ No newline at end of file diff --git a/Day61-65/code/tesseract.png b/Day61-65/code/tesseract.png new file mode 100644 index 0000000..4f598b0 Binary files /dev/null and b/Day61-65/code/tesseract.png differ diff --git a/Day61-65/res/.gitkeep b/Day61-65/res/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Day61-65/res/api-image360.png b/Day61-65/res/api-image360.png new file mode 100644 index 0000000..eaabc6a Binary files /dev/null and b/Day61-65/res/api-image360.png differ diff --git a/Day61-65/res/baidu-search-taobao.png b/Day61-65/res/baidu-search-taobao.png new file mode 100644 index 0000000..d5ad08e Binary files /dev/null and b/Day61-65/res/baidu-search-taobao.png differ diff --git a/Day61-65/res/chrome-developer-tools.png b/Day61-65/res/chrome-developer-tools.png new file mode 100644 index 0000000..c4be32c Binary files /dev/null and b/Day61-65/res/chrome-developer-tools.png differ diff --git a/Day61-65/res/crawler-workflow.png b/Day61-65/res/crawler-workflow.png new file mode 100644 index 0000000..4175285 Binary files /dev/null and b/Day61-65/res/crawler-workflow.png differ diff --git a/Day61-65/res/douban-xpath.png b/Day61-65/res/douban-xpath.png new file mode 100644 index 0000000..39e49d7 Binary files /dev/null and b/Day61-65/res/douban-xpath.png differ diff --git a/Day61-65/res/http-request.png b/Day61-65/res/http-request.png new file mode 100644 index 0000000..67d0fb6 Binary files /dev/null and b/Day61-65/res/http-request.png differ diff --git a/Day61-65/res/http-response.png b/Day61-65/res/http-response.png new file mode 100644 index 0000000..0de1144 Binary files /dev/null and b/Day61-65/res/http-response.png differ diff --git a/Day61-65/res/image360-website.png b/Day61-65/res/image360-website.png new file mode 100644 index 0000000..e394332 Binary files /dev/null and b/Day61-65/res/image360-website.png differ diff --git a/Day61-65/res/postman.png b/Day61-65/res/postman.png new file mode 100644 index 0000000..ed95b94 Binary files /dev/null and b/Day61-65/res/postman.png differ diff --git a/Day61-65/res/redis-save.png b/Day61-65/res/redis-save.png new file mode 100644 index 0000000..ddc0528 Binary files /dev/null and b/Day61-65/res/redis-save.png differ diff --git a/Day61-65/res/run-hello-world-app.png b/Day61-65/res/run-hello-world-app.png deleted file mode 100644 index f744358..0000000 Binary files a/Day61-65/res/run-hello-world-app.png and /dev/null differ diff --git a/Day61-65/res/scrapy-architecture.png b/Day61-65/res/scrapy-architecture.png new file mode 100644 index 0000000..5a96766 Binary files /dev/null and b/Day61-65/res/scrapy-architecture.png differ diff --git a/Day61-65/res/tesseract.gif b/Day61-65/res/tesseract.gif new file mode 100644 index 0000000..c5476f3 Binary files /dev/null and b/Day61-65/res/tesseract.gif differ diff --git a/Day61-65/res/websocket.png b/Day61-65/res/websocket.png deleted file mode 100644 index 7973399..0000000 Binary files a/Day61-65/res/websocket.png and /dev/null differ diff --git a/Day61-65/res/ws_wss.png b/Day61-65/res/ws_wss.png deleted file mode 100644 index ac4b0e5..0000000 Binary files a/Day61-65/res/ws_wss.png and /dev/null differ diff --git a/Day66-70/66.数据分析概述.md b/Day66-70/66.数据分析概述.md new file mode 100644 index 0000000..a051cce --- /dev/null +++ b/Day66-70/66.数据分析概述.md @@ -0,0 +1,2 @@ +## NumPy的应用 + diff --git a/Day66-70/67.NumPy的应用.md b/Day66-70/67.NumPy的应用.md new file mode 100644 index 0000000..a051cce --- /dev/null +++ b/Day66-70/67.NumPy的应用.md @@ -0,0 +1,2 @@ +## NumPy的应用 + diff --git a/Day76-90/77.Pandas的应用.md b/Day66-70/68.Pandas的应用.md similarity index 100% rename from Day76-90/77.Pandas的应用.md rename to Day66-70/68.Pandas的应用.md diff --git a/Day76-90/79.Matplotlib和数据可视化.md b/Day66-70/69.数据可视化.md similarity index 99% rename from Day76-90/79.Matplotlib和数据可视化.md rename to Day66-70/69.数据可视化.md index c451975..9f0cbf4 100644 --- a/Day76-90/79.Matplotlib和数据可视化.md +++ b/Day66-70/69.数据可视化.md @@ -1,4 +1,4 @@ -## Matplotlib和数据可视化 +## 数据可视化 数据的处理、分析和可视化已经成为Python近年来最为重要的应用领域之一,其中数据的可视化指的是将数据呈现为漂亮的统计图表,然后进一步发现数据中包含的规律以及隐藏的信息。数据可视化又跟数据挖掘和大数据分析紧密相关,而这些领域以及当下被热议的“深度学习”其最终的目标都是为了实现从过去的数据去对未来的状况进行预测。Python在实现数据可视化方面是非常棒的,即便是使用个人电脑也能够实现对百万级甚至更大体量的数据进行探索的工作,而这些工作都可以在现有的第三方库的基础上来完成(无需“重复的发明轮子”)。[Matplotlib](https://matplotlib.org/)就是Python绘图库中的佼佼者,它包含了大量的工具,你可以使用这些工具创建各种图形(包括散点图、折线图、直方图、饼图、雷达图等),Python科学计算社区也经常使用它来完成数据可视化的工作。 diff --git a/Day66-70/70.数据分析项目实战.md b/Day66-70/70.数据分析项目实战.md new file mode 100644 index 0000000..09158a7 --- /dev/null +++ b/Day66-70/70.数据分析项目实战.md @@ -0,0 +1,2 @@ +## 数据分析项目实战 + diff --git a/Day66-70/res/result-in-jupyter.png b/Day66-70/res/result-in-jupyter.png new file mode 100644 index 0000000..a98c76d Binary files /dev/null and b/Day66-70/res/result-in-jupyter.png differ diff --git a/Day66-70/res/result1.png b/Day66-70/res/result1.png new file mode 100644 index 0000000..9b1feca Binary files /dev/null and b/Day66-70/res/result1.png differ diff --git a/Day66-70/res/result2.png b/Day66-70/res/result2.png new file mode 100644 index 0000000..0398869 Binary files /dev/null and b/Day66-70/res/result2.png differ diff --git a/Day66-70/res/result3.png b/Day66-70/res/result3.png new file mode 100644 index 0000000..a9ebe77 Binary files /dev/null and b/Day66-70/res/result3.png differ diff --git a/Day66-70/res/result4.png b/Day66-70/res/result4.png new file mode 100644 index 0000000..a02e7f1 Binary files /dev/null and b/Day66-70/res/result4.png differ diff --git a/Day66-70/res/result5.png b/Day66-70/res/result5.png new file mode 100644 index 0000000..178ed9a Binary files /dev/null and b/Day66-70/res/result5.png differ diff --git a/Day66-70/res/result6.png b/Day66-70/res/result6.png new file mode 100644 index 0000000..63ac845 Binary files /dev/null and b/Day66-70/res/result6.png differ diff --git a/Day66-70/res/result7.png b/Day66-70/res/result7.png new file mode 100644 index 0000000..c8c2e26 Binary files /dev/null and b/Day66-70/res/result7.png differ diff --git a/Day66-70/res/result8.png b/Day66-70/res/result8.png new file mode 100644 index 0000000..694b796 Binary files /dev/null and b/Day66-70/res/result8.png differ diff --git a/Day66-70/res/result9.png b/Day66-70/res/result9.png new file mode 100644 index 0000000..bb6bbc3 Binary files /dev/null and b/Day66-70/res/result9.png differ diff --git a/Day66-75/68.存储数据.md b/Day66-75/68.存储数据.md deleted file mode 100644 index 6ad2af2..0000000 --- a/Day66-75/68.存储数据.md +++ /dev/null @@ -1,66 +0,0 @@ -## 存储数据 - -### 存储海量数据 - -数据持久化的首选方案应该是关系型数据库,关系型数据库的产品很多,包括:Oracle、MySQL、SQLServer、PostgreSQL等。如果要存储海量的低价值数据,文档数据库也是不错的选择,MongoDB是文档数据库中的佼佼者,之前我们已经讲解过MongDB的相关知识,在此不再进行赘述。 - -### 数据缓存 - -通过[《网络数据采集和解析》](./02.数据采集和解析.md)一文,我们已经知道了如何从指定的页面中抓取数据,以及如何保存抓取的结果,但是我们没有考虑过这么一种情况,就是我们可能需要从已经抓取过的页面中提取出更多的数据,重新去下载这些页面对于规模不大的网站倒是问题也不大,但是如果能够把这些页面缓存起来,对应用的性能会有明显的改善。可以使用Redis来提供高速缓存服务,关于Redis的知识,我们在[《NoSQL入门》](../Day36-40/NoSQL入门.md)一文中已经做过简要的介绍。 - -### 实例 - 缓存知乎发现上的链接和页面代码 - -```Python -from hashlib import sha1 -from urllib.parse import urljoin - -import pickle -import re -import requests -import zlib - -from bs4 import BeautifulSoup -from redis import Redis - - -def main(): - # 指定种子页面 - base_url = 'https://www.zhihu.com/' - seed_url = urljoin(base_url, 'explore') - # 创建Redis客户端 - client = Redis(host='1.2.3.4', port=6379, password='1qaz2wsx') - # 设置用户代理(否则访问会被拒绝) - headers = {'user-agent': 'Baiduspider'} - # 通过requests模块发送GET请求并指定用户代理 - resp = requests.get(seed_url, headers=headers) - # 创建BeautifulSoup对象并指定使用lxml作为解析器 - soup = BeautifulSoup(resp.text, 'lxml') - href_regex = re.compile(r'^/question') - # 将URL处理成SHA1摘要(长度固定更简短) - hasher_proto = sha1() - # 查找所有href属性以/question打头的a标签 - for a_tag in soup.find_all('a', {'href': href_regex}): - # 获取a标签的href属性值并组装完整的URL - href = a_tag.attrs['href'] - full_url = urljoin(base_url, href) - # 传入URL生成SHA1摘要 - hasher = hasher_proto.copy() - hasher.update(full_url.encode('utf-8')) - field_key = hasher.hexdigest() - # 如果Redis的键'zhihu'对应的hash数据类型中没有URL的摘要就访问页面并缓存 - if not client.hexists('zhihu', field_key): - html_page = requests.get(full_url, headers=headers).text - # 对页面进行序列化和压缩操作 - zipped_page = zlib.compress(pickle.dumps(html_page)) - # 使用hash数据类型保存URL摘要及其对应的页面代码 - client.hset('zhihu', field_key, zipped_page) - # 显示总共缓存了多少个页面 - print('Total %d question pages found.' % client.hlen('zhihu')) - - -if __name__ == '__main__': - main() -``` - - - diff --git a/Day66-75/71.表单交互和验证码处理.md b/Day66-75/71.表单交互和验证码处理.md deleted file mode 100644 index e0e9c28..0000000 --- a/Day66-75/71.表单交互和验证码处理.md +++ /dev/null @@ -1,32 +0,0 @@ -## 表单交互和验证码处理 - -### 提交表单 - -#### 手动提交 - - - -#### 自动提交 - - - -### 验证码处理 - -#### 加载验证码 - - - -#### 光学字符识别 - -光学字符识别(OCR)是从图像中抽取文本的工具,可以应用于公安、电信、物流、金融等诸多行业,例如识别车牌,身份证扫描识别、名片信息提取等。在爬虫开发中,如果遭遇了有文字验证码的表单,就可以利用OCR来进行验证码处理。Tesseract-OCR引擎最初是由惠普公司开发的光学字符识别系统,目前发布在Github上,由Google赞助开发。 - -![](./res/tesseract.gif) - - - -#### 处理更复杂的验证码 - -很多网站为了分别出提供验证码的是人还是机器使用了更为复杂的验证码,例如拼图验证码、点触验证码、九宫格验证码等。关于这方面的知识,在崔庆才同学的[《Python 3网络爬虫开发实战》](http://www.ituring.com.cn/book/2003)有较为详细的讲解,有兴趣的可以购买阅读。 - -#### 验证码处理服务 - diff --git a/Day66-75/72.Scrapy入门.md b/Day66-75/72.Scrapy入门.md deleted file mode 100644 index aaaab43..0000000 --- a/Day66-75/72.Scrapy入门.md +++ /dev/null @@ -1,304 +0,0 @@ -## Scrapy爬虫框架入门 - -### Scrapy概述 - -Scrapy是Python开发的一个非常流行的网络爬虫框架,可以用来抓取Web站点并从页面中提取结构化的数据,被广泛的用于数据挖掘、数据监测和自动化测试等领域。下图展示了Scrapy的基本架构,其中包含了主要组件和系统的数据处理流程(图中带数字的红色箭头)。 - -![](./res/scrapy-architecture.png) - -#### 组件 - -1. Scrapy引擎(Engine):Scrapy引擎是用来控制整个系统的数据处理流程。 -2. 调度器(Scheduler):调度器从Scrapy引擎接受请求并排序列入队列,并在Scrapy引擎发出请求后返还给它们。 -3. 下载器(Downloader):下载器的主要职责是抓取网页并将网页内容返还给蜘蛛(Spiders)。 -4. 蜘蛛(Spiders):蜘蛛是有Scrapy用户自定义的用来解析网页并抓取特定URL返回的内容的类,每个蜘蛛都能处理一个域名或一组域名,简单的说就是用来定义特定网站的抓取和解析规则。 -5. 条目管道(Item Pipeline):条目管道的主要责任是负责处理有蜘蛛从网页中抽取的数据条目,它的主要任务是清理、验证和存储数据。当页面被蜘蛛解析后,将被发送到条目管道,并经过几个特定的次序处理数据。每个条目管道组件都是一个Python类,它们获取了数据条目并执行对数据条目进行处理的方法,同时还需要确定是否需要在条目管道中继续执行下一步或是直接丢弃掉不处理。条目管道通常执行的任务有:清理HTML数据、验证解析到的数据(检查条目是否包含必要的字段)、检查是不是重复数据(如果重复就丢弃)、将解析到的数据存储到数据库(关系型数据库或NoSQL数据库)中。 -6. 中间件(Middlewares):中间件是介于Scrapy引擎和其他组件之间的一个钩子框架,主要是为了提供自定义的代码来拓展Scrapy的功能,包括下载器中间件和蜘蛛中间件。 - -#### 数据处理流程 - -Scrapy的整个数据处理流程由Scrapy引擎进行控制,通常的运转流程包括以下的步骤: - -1. 引擎询问蜘蛛需要处理哪个网站,并让蜘蛛将第一个需要处理的URL交给它。 - -2. 引擎让调度器将需要处理的URL放在队列中。 - -3. 引擎从调度那获取接下来进行爬取的页面。 - -4. 调度将下一个爬取的URL返回给引擎,引擎将它通过下载中间件发送到下载器。 - -5. 当网页被下载器下载完成以后,响应内容通过下载中间件被发送到引擎;如果下载失败了,引擎会通知调度器记录这个URL,待会再重新下载。 - -6. 引擎收到下载器的响应并将它通过蜘蛛中间件发送到蜘蛛进行处理。 - -7. 蜘蛛处理响应并返回爬取到的数据条目,此外还要将需要跟进的新的URL发送给引擎。 - -8. 引擎将抓取到的数据条目送入条目管道,把新的URL发送给调度器放入队列中。 - -上述操作中的2-8步会一直重复直到调度器中没有需要请求的URL,爬虫停止工作。 - -### 安装和使用Scrapy - -可以先创建虚拟环境并在虚拟环境下使用pip安装scrapy。 - -```Shell - -``` - -项目的目录结构如下图所示。 - -```Shell -(venv) $ tree -. -|____ scrapy.cfg -|____ douban -| |____ spiders -| | |____ __init__.py -| | |____ __pycache__ -| |____ __init__.py -| |____ __pycache__ -| |____ middlewares.py -| |____ settings.py -| |____ items.py -| |____ pipelines.py -``` - -> 说明:Windows系统的命令行提示符下有tree命令,但是Linux和MacOS的终端是没有tree命令的,可以用下面给出的命令来定义tree命令,其实是对find命令进行了定制并别名为tree。 -> -> `alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"` -> -> Linux系统也可以通过yum或其他的包管理工具来安装tree。 -> -> `yum install tree` - -根据刚才描述的数据处理流程,基本上需要我们做的有以下几件事情: - -1. 在items.py文件中定义字段,这些字段用来保存数据,方便后续的操作。 - - ```Python - # -*- coding: utf-8 -*- - - # Define here the models for your scraped items - # - # See documentation in: - # https://doc.scrapy.org/en/latest/topics/items.html - - import scrapy - - - class DoubanItem(scrapy.Item): - - name = scrapy.Field() - year = scrapy.Field() - score = scrapy.Field() - director = scrapy.Field() - classification = scrapy.Field() - actor = scrapy.Field() - ``` - -2. 在spiders文件夹中编写自己的爬虫。 - - ```Shell - (venv) $ scrapy genspider movie movie.douban.com --template=crawl - ``` - - ```Python - # -*- coding: utf-8 -*- - import scrapy - from scrapy.selector import Selector - from scrapy.linkextractors import LinkExtractor - from scrapy.spiders import CrawlSpider, Rule - - from douban.items import DoubanItem - - - class MovieSpider(CrawlSpider): - name = 'movie' - allowed_domains = ['movie.douban.com'] - start_urls = ['https://movie.douban.com/top250'] - rules = ( - Rule(LinkExtractor(allow=(r'https://movie.douban.com/top250\?start=\d+.*'))), - Rule(LinkExtractor(allow=(r'https://movie.douban.com/subject/\d+')), callback='parse_item'), - ) - - def parse_item(self, response): - sel = Selector(response) - item = DoubanItem() - item['name']=sel.xpath('//*[@id="content"]/h1/span[1]/text()').extract() - item['year']=sel.xpath('//*[@id="content"]/h1/span[2]/text()').re(r'\((\d+)\)') - item['score']=sel.xpath('//*[@id="interest_sectl"]/div/p[1]/strong/text()').extract() - item['director']=sel.xpath('//*[@id="info"]/span[1]/a/text()').extract() - item['classification']= sel.xpath('//span[@property="v:genre"]/text()').extract() - item['actor']= sel.xpath('//*[@id="info"]/span[3]/a[1]/text()').extract() - return item - ``` - > 说明:上面我们通过Scrapy提供的爬虫模板创建了Spider,其中的rules中的LinkExtractor对象会自动完成对新的链接的解析,该对象中有一个名为extract_link的回调方法。Scrapy支持用XPath语法和CSS选择器进行数据解析,对应的方法分别是xpath和css,上面我们使用了XPath语法对页面进行解析,如果不熟悉XPath语法可以看看后面的补充说明。 - - 到这里,我们已经可以通过下面的命令让爬虫运转起来。 - - ```Shell - (venv)$ scrapy crawl movie - ``` - - 可以在控制台看到爬取到的数据,如果想将这些数据保存到文件中,可以通过`-o`参数来指定文件名,Scrapy支持我们将爬取到的数据导出成JSON、CSV、XML、pickle、marshal等格式。 - - ```Shell - (venv)$ scrapy crawl moive -o result.json - ``` - -3. 在pipelines.py中完成对数据进行持久化的操作。 - - ```Python - # -*- coding: utf-8 -*- - - # Define your item pipelines here - # - # Don't forget to add your pipeline to the ITEM_PIPELINES setting - # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html - import pymongo - - from scrapy.exceptions import DropItem - from scrapy.conf import settings - from scrapy import log - - - class DoubanPipeline(object): - - def __init__(self): - connection = pymongo.MongoClient(settings['MONGODB_SERVER'], settings['MONGODB_PORT']) - db = connection[settings['MONGODB_DB']] - self.collection = db[settings['MONGODB_COLLECTION']] - - def process_item(self, item, spider): - #Remove invalid data - valid = True - for data in item: - if not data: - valid = False - raise DropItem("Missing %s of blogpost from %s" %(data, item['url'])) - if valid: - #Insert data into database - new_moive=[{ - "name":item['name'][0], - "year":item['year'][0], - "score":item['score'], - "director":item['director'], - "classification":item['classification'], - "actor":item['actor'] - }] - self.collection.insert(new_moive) - log.msg("Item wrote to MongoDB database %s/%s" % - (settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), - level=log.DEBUG, spider=spider) - return item - - ``` - 利用Pipeline我们可以完成以下操作: - - - 清理HTML数据,验证爬取的数据。 - - 丢弃重复的不必要的内容。 - - 将爬取的结果进行持久化操作。 - -4. 修改settings.py文件对项目进行配置。 - - ```Python - # -*- coding: utf-8 -*- - - # Scrapy settings for douban project - # - # For simplicity, this file contains only settings considered important or - # commonly used. You can find more settings consulting the documentation: - # - # https://doc.scrapy.org/en/latest/topics/settings.html - # https://doc.scrapy.org/en/latest/topics/downloader-middleware.html - # https://doc.scrapy.org/en/latest/topics/spider-middleware.html - - BOT_NAME = 'douban' - - SPIDER_MODULES = ['douban.spiders'] - NEWSPIDER_MODULE = 'douban.spiders' - - - # Crawl responsibly by identifying yourself (and your website) on the user-agent - USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.54 Safari/536.5' - - # Obey robots.txt rules - ROBOTSTXT_OBEY = True - - # Configure maximum concurrent requests performed by Scrapy (default: 16) - # CONCURRENT_REQUESTS = 32 - - # Configure a delay for requests for the same website (default: 0) - # See https://doc.scrapy.org/en/latest/topics/settings.html#download-delay - # See also autothrottle settings and docs - DOWNLOAD_DELAY = 3 - RANDOMIZE_DOWNLOAD_DELAY = True - # The download delay setting will honor only one of: - # CONCURRENT_REQUESTS_PER_DOMAIN = 16 - # CONCURRENT_REQUESTS_PER_IP = 16 - - # Disable cookies (enabled by default) - COOKIES_ENABLED = True - - MONGODB_SERVER = '120.77.222.217' - MONGODB_PORT = 27017 - MONGODB_DB = 'douban' - MONGODB_COLLECTION = 'movie' - - # Disable Telnet Console (enabled by default) - # TELNETCONSOLE_ENABLED = False - - # Override the default request headers: - # DEFAULT_REQUEST_HEADERS = { - # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - # 'Accept-Language': 'en', - # } - - # Enable or disable spider middlewares - # See https://doc.scrapy.org/en/latest/topics/spider-middleware.html - # SPIDER_MIDDLEWARES = { - # 'douban.middlewares.DoubanSpiderMiddleware': 543, - # } - - # Enable or disable downloader middlewares - # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html - # DOWNLOADER_MIDDLEWARES = { - # 'douban.middlewares.DoubanDownloaderMiddleware': 543, - # } - - # Enable or disable extensions - # See https://doc.scrapy.org/en/latest/topics/extensions.html - # EXTENSIONS = { - # 'scrapy.extensions.telnet.TelnetConsole': None, - # } - - # Configure item pipelines - # See https://doc.scrapy.org/en/latest/topics/item-pipeline.html - ITEM_PIPELINES = { - 'douban.pipelines.DoubanPipeline': 400, - } - - LOG_LEVEL = 'DEBUG' - - # Enable and configure the AutoThrottle extension (disabled by default) - # See https://doc.scrapy.org/en/latest/topics/autothrottle.html - #AUTOTHROTTLE_ENABLED = True - # The initial download delay - #AUTOTHROTTLE_START_DELAY = 5 - # The maximum download delay to be set in case of high latencies - #AUTOTHROTTLE_MAX_DELAY = 60 - # The average number of requests Scrapy should be sending in parallel to - # each remote server - #AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0 - # Enable showing throttling stats for every response received: - #AUTOTHROTTLE_DEBUG = False - - # Enable and configure HTTP caching (disabled by default) - # See https://doc.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings - HTTPCACHE_ENABLED = True - HTTPCACHE_EXPIRATION_SECS = 0 - HTTPCACHE_DIR = 'httpcache' - HTTPCACHE_IGNORE_HTTP_CODES = [] - HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage' - ``` - diff --git a/Day66-75/73.Scrapy高级应用.md b/Day66-75/73.Scrapy高级应用.md deleted file mode 100644 index 264c3c2..0000000 --- a/Day66-75/73.Scrapy高级应用.md +++ /dev/null @@ -1,32 +0,0 @@ -## Scrapy爬虫框架高级应用 - -### Spider的用法 - -在Scrapy框架中,我们自定义的蜘蛛都继承自scrapy.spiders.Spider,这个类有一系列的属性和方法,具体如下所示: - -1. name:爬虫的名字。 -2. allowed_domains:允许爬取的域名,不在此范围的链接不会被跟进爬取。 -3. start_urls:起始URL列表,当我们没有重写start_requests()方法时,就会从这个列表开始爬取。 -4. custom_settings:用来存放蜘蛛专属配置的字典,这里的设置会覆盖全局的设置。 -5. crawler:由from_crawler()方法设置的和蜘蛛对应的Crawler对象,Crawler对象包含了很多项目组件,利用它我们可以获取项目的配置信息,如调用crawler.settings.get()方法。 -6. settings:用来获取爬虫全局设置的变量。 -7. start_requests():此方法用于生成初始请求,它返回一个可迭代对象。该方法默认是使用GET请求访问起始URL,如果起始URL需要使用POST请求来访问就必须重写这个方法。 -8. parse():当Response没有指定回调函数时,该方法就会被调用,它负责处理Response对象并返回结果,从中提取出需要的数据和后续的请求,该方法需要返回类型为Request或Item的可迭代对象(生成器当前也包含在其中,因此根据实际需要可以用return或yield来产生返回值)。 -9. closed():当蜘蛛关闭时,该方法会被调用,通常用来做一些释放资源的善后操作。 - -### 中间件的应用 - -#### 下载中间件 - - - -#### 蜘蛛中间件 - - - -### Scrapy对接Selenium - - - -### Scrapy部署到Docker - diff --git a/Day66-75/74.Scrapy分布式实现.md b/Day66-75/74.Scrapy分布式实现.md deleted file mode 100644 index 9fe53d1..0000000 --- a/Day66-75/74.Scrapy分布式实现.md +++ /dev/null @@ -1,30 +0,0 @@ -## Scrapy爬虫框架分布式实现 - -### 分布式爬虫原理 - - - -### Scrapy分布式实现 - -1. 安装Scrapy-Redis。 -2. 配置Redis服务器。 -3. 修改配置文件。 - - SCHEDULER = 'scrapy_redis.scheduler.Scheduler' - - DUPEFILTER_CLASS = 'scrapy_redis.dupefilter.RFPDupeFilter' - - REDIS_HOST = '1.2.3.4' - - REDIS_PORT = 6379 - - REDIS_PASSWORD = '1qaz2wsx' - - SCHEDULER_QUEUE_CLASS = 'scrapy_redis.queue.FifoQueue' - - SCHEDULER_PERSIST = True(通过持久化支持接续爬取) - - SCHEDULER_FLUSH_ON_START = True(每次启动时重新爬取) - -### Scrapyd分布式部署 - -1. 安装Scrapyd -2. 修改配置文件 - - mkdir /etc/scrapyd - - vim /etc/scrapyd/scrapyd.conf -3. 安装Scrapyd-Client - - 将项目打包成Egg文件。 - - 将打包的Egg文件通过addversion.json接口部署到Scrapyd上。 - diff --git a/Day66-75/75.爬虫项目实战.md b/Day66-75/75.爬虫项目实战.md deleted file mode 100644 index 43bdc89..0000000 --- a/Day66-75/75.爬虫项目实战.md +++ /dev/null @@ -1 +0,0 @@ -## 爬虫项目实战 diff --git a/Day66-75/code/douban/douban/__init__.py b/Day66-75/code/douban/douban/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Day66-75/code/douban/result.json b/Day66-75/code/douban/result.json deleted file mode 100644 index e69de29..0000000 diff --git a/Day66-75/code/guido.jpg b/Day66-75/code/guido.jpg deleted file mode 100644 index 78f71ae..0000000 Binary files a/Day66-75/code/guido.jpg and /dev/null differ diff --git a/Day66-75/code/image360/image360/__init__.py b/Day66-75/code/image360/image360/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Day66-75/code/tesseract.png b/Day66-75/code/tesseract.png deleted file mode 100644 index 315cf94..0000000 Binary files a/Day66-75/code/tesseract.png and /dev/null differ diff --git a/Day66-75/res/api-image360.png b/Day66-75/res/api-image360.png deleted file mode 100644 index 2e4a406..0000000 Binary files a/Day66-75/res/api-image360.png and /dev/null differ diff --git a/Day66-75/res/baidu-search-taobao.png b/Day66-75/res/baidu-search-taobao.png deleted file mode 100644 index d013ba8..0000000 Binary files a/Day66-75/res/baidu-search-taobao.png and /dev/null differ diff --git a/Day66-75/res/chrome-developer-tools.png b/Day66-75/res/chrome-developer-tools.png deleted file mode 100644 index aad8fc7..0000000 Binary files a/Day66-75/res/chrome-developer-tools.png and /dev/null differ diff --git a/Day66-75/res/crawler-workflow.png b/Day66-75/res/crawler-workflow.png deleted file mode 100644 index 9adf5fd..0000000 Binary files a/Day66-75/res/crawler-workflow.png and /dev/null differ diff --git a/Day66-75/res/douban-xpath.png b/Day66-75/res/douban-xpath.png deleted file mode 100644 index 3ecb737..0000000 Binary files a/Day66-75/res/douban-xpath.png and /dev/null differ diff --git a/Day66-75/res/http-request.png b/Day66-75/res/http-request.png deleted file mode 100644 index aca9287..0000000 Binary files a/Day66-75/res/http-request.png and /dev/null differ diff --git a/Day66-75/res/http-response.png b/Day66-75/res/http-response.png deleted file mode 100644 index f2b8ae3..0000000 Binary files a/Day66-75/res/http-response.png and /dev/null differ diff --git a/Day66-75/res/image360-website.png b/Day66-75/res/image360-website.png deleted file mode 100644 index ffbb0d1..0000000 Binary files a/Day66-75/res/image360-website.png and /dev/null differ diff --git a/Day66-75/res/postman.png b/Day66-75/res/postman.png deleted file mode 100644 index 0e9b6ed..0000000 Binary files a/Day66-75/res/postman.png and /dev/null differ diff --git a/Day66-75/res/redis-save.png b/Day66-75/res/redis-save.png deleted file mode 100644 index d721dd8..0000000 Binary files a/Day66-75/res/redis-save.png and /dev/null differ diff --git a/Day66-75/res/scrapy-architecture.png b/Day66-75/res/scrapy-architecture.png deleted file mode 100644 index 5fe393f..0000000 Binary files a/Day66-75/res/scrapy-architecture.png and /dev/null differ diff --git a/Day66-75/res/tesseract.gif b/Day66-75/res/tesseract.gif deleted file mode 100644 index 4df18a7..0000000 Binary files a/Day66-75/res/tesseract.gif and /dev/null differ diff --git a/Day71-85/71.人工智能和机器学习概述.md b/Day71-85/71.人工智能和机器学习概述.md new file mode 100644 index 0000000..3241f6f --- /dev/null +++ b/Day71-85/71.人工智能和机器学习概述.md @@ -0,0 +1,130 @@ +## 人工智能和机器学习概述 + +所谓“人工智能”通常是泛指让机器具有像人一样的智慧的技术,其目的是让机器像人一样能够感知、思考和解决问题;而“机器学习”通常是指让计算机通过学习现有的数据,实现认知的更新和进步。显然,机器学习是实现人工智能的一种途径,这也是我们的课程要讨论的内容。现如今,“机器学习”和“大数据”可以说是最时髦的两个词汇,而在弱人工智能阶段,无论是“机器学习”还是“大数据”最终要解决的问题本质上是一样的,就是让计算机将纷繁复杂的数据处理成有用的信息,这样就可以发掘出数据带来的意义以及隐藏在数据背后的规律,简单的说就是用现有的数据对将来的状况做出预测和判断。 + +在讨论机器学习相关内容之前,我们先按照问题的“输入”和“输出”对用计算机求解的问题进行一个分类,如下所示: + +1. 输入的信息是精确的,要求输出最优解。 +2. 输入的信息是精确的,无法找到最优解,只能获得满意解。 +3. 输入的信息是模糊的,要求输出最优解。 +4. 输入的信息是模糊的,无法找到最优解,只能获得满意解。 + +在上面的四大类问题中,第1类问题是计算机最擅长解决的,这类问题其实就是“数值计算”和“逻辑推理”方面的问题,而传统意义上的人工智能也就是利用逻辑推理来解决问题(如早期的“人机对弈”)。一直以来,我们都习惯于将计算机称为“电脑”,而基于“冯诺依曼”体系结构的“电脑”实际上只是实现了“人脑”理性思维这部分的功能,而且在这一点上“电脑”的表现通常是优于“人脑”的;但是“人脑”在处理模糊输入信息时表现出来的强大处理能力,在很多场景下“电脑”是难以企及的。所以我们研究机器学习的算法,就是要解决在输入模糊信息时让计算机给出满意解甚至是最优解的问题。 + +人类通过记忆和归纳这两种方式进行学习,通过记忆可以积累单个事实,使用归纳可以从旧的事实推导出新的事实。所以机器学习其实是一种训练,让计算机通过这种训练能够学会根据数据隐含模式进行合理推断的能力,其基本流程如下所示: + +1. 观察一组实例,通常称为训练数据,它们可以表示某种统计现象的不完整信息; +2. 对观测到的实例进行扩展,并使用推断技术对扩展过程建模; +3. 使用这个模型对未知实例进行预测。 + +### 基本概念 + +#### 监督学习和非监督学习 + +监督学习是从给定的训练数据集中学习得到一个函数,当新的数据到来时,可以根据这个函数预测结果,监督学习的训练集包括输入和输出,也可以说是特征和目标。监督学习的目标是由人来标注的,而非监督学习的数据没有类别信息,训练集也没有人为标注结果,通过无监督学习可以减少数据特征的维度,以便我们可以使用二维或三维图形更加直观地展示数据中的信息 。 + +#### 特征向量和特征工程 + + + +#### 距离度量 + + + +1. 欧氏距离 + +$$ +d = \sqrt{\sum_{k=1}^n(x_{1k}-x_{2k})^2} +$$ + +2. 曼哈顿距离 + +$$ +d = \sum_{k=1}^n \mid {x_{1k}-x_{2k}} \mid +$$ + +3. 切比雪夫距离 + +$$ +d = max(\mid x_{1k}-x_{2k} \mid) +$$ + +4. 闵可夫斯基距离 + - 当$p=1$时,就是曼哈顿距离 + - 当$p=2$时,就是欧式距离 + - 当$p \to \infty$时,就是切比雪夫距离 + +$$ +d = \sqrt[p]{\sum_{k=1}^n \mid x_{1k}-x_{2k} \mid ^p} +$$ + +5. 余弦距离 + $$ + cos(\theta) = \frac{\sum_{k=1}^n x_{1k}x_{2k}}{\sqrt{\sum_{k=1}^n x_{1k}^2} \sqrt{\sum_{k=1}^n x_{2k}^2}} + $$ + +### 机器学习的定义和应用领域 + +根据上面的论述,我们可以给“机器学习”下一个正式的定义:**机器学习是一门专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身性能的学科**。即使对于机器学习这个概念不那么熟悉,但是机器学习的成果已经广泛渗透到了生产生活的各个领域,下面的这些场景对于你来说一定不陌生。 + +场景1:搜索引擎会根据搜索和使用习惯,优化下一次搜索的结果。 + +场景2:电商网站会根据你的访问历史自动推荐你可能感兴趣的商品。 + +场景3:金融类产品会通过你最近的金融活动信息综合评定你的贷款申请。 + +场景4:视频和直播平台会自动识别图片和视频中有没有不和谐的内容。 + +场景5:智能家电和智能汽车会根据你的语音指令做出相应的动作。 + +简单的总结一下,机器学习可以应用到但不限于以下领域: + +1. 计算机视觉。计算机视觉是指机器感知环境的能力,目前在[**物体检测**](https://pjreddie.com/darknet/yolo/)和**人脸识别**这两个领域已经非常成熟且产生了大量的应用。 + + - 刷脸支付 + + ![](res/face_paying.png) + + - [涂鸦识别](https://quickdraw.withgoogle.com/) + + ![](res/quickdraw.png) + +2. 自然语言处理(NLP)。自然语言处理是目前机器学习中一个非常热门的分支,具体的又可以分为三类应用场景。其中文本挖掘主要是对文本进行分类,包括句法分析、情绪分析和垃圾信息检测等;而机器翻译和语音识别相信不用太多的解释大家也都清楚。 + + - 文本挖掘 + - 机器翻译 + + - 语音识别 + + ![](res/xiaomi_ai_voice_box.png) + +3. 机器人。机器人可以分为固定机器人和移动机器人两大类。固定机器人通常被用于工业生产,例如用于装配流水线。常见的移动机器人应用有货运机器人、空中机器人和自动载具。机器人需要软硬件的协作才能实现最优的作业,其中硬件包含传感器、反应器和控制器等,而软件主要是实现感知能力,包括定位、测绘、目标检测和识别等。 + + - 机甲大师 + + ![](res/dajiang_robomaster.png) + + - 扫地机器人 + + ![](res/sweep_robot.jpg) + +### 机器学习实施步骤 + +实现机器学习的一般步骤: + +1. 数据收集 +2. 数据准备 +3. 数据分析 +4. 训练算法 +5. 测试算法 +6. 应用算法 + +### Scikit-learn介绍 + +![](res/scikit-learn-logo.png) + +Scikit-learn源于Google Summer of Code项目,由David Cournapeau在2007年发起,它提供了机器学习可能用到的工具,包括数据预处理、监督学习(分类、回归)、非监督学习(聚类)、模型选择、降维等。 + +官网地址: + +安装方法:`pip install scikit-learn` \ No newline at end of file diff --git a/Day71-85/72.k最近邻分类.md b/Day71-85/72.k最近邻分类.md new file mode 100644 index 0000000..1568098 --- /dev/null +++ b/Day71-85/72.k最近邻分类.md @@ -0,0 +1,35 @@ +## k最近邻分类 + +$k$最近邻(简称kNN,k-Nearest Neighbor)是Cover和Hart在1968年提出的一种简单的监督学习算法,可用于字符识别、文本分类、图像识别等领域。kNN的工作机制非常简单:给定测试样本,基于某种距离度量(如:欧式距离、曼哈顿距离等)找出训练集中与其最接近的$k$个训练样本,然后基于这$k$个“最近邻居”的信息来进行预测。对于分类任务,可以在$k$个最近邻居中选择出现次数最多的类别标签作为预测的结果;对于回归任务,可以使用$k$个最近邻居实际输出(目标值)的平均值作为预测的结果,当然也可以根据距离的远近进行加权平均,距离越近的样本权重值就越大。 + +### 案例:电影分类预测 + + + +### k值的选择和交叉检验 + +k值的选择对于kNN算法的结果有非常显著的影响。下面用李航博士的《统计学习方法》一书中的叙述,来对k值的选择加以说明。 + +如果选择较小的$k$值,就相当于用较小的邻域中的训练实例进行预测,“学习”的近似误差会减小,只有与输入实例较近(相似的)训练实例才会对预测结果起作用;但缺点是“学习”的估计误差会增大,预测结果会对近邻的实例点非常敏感,如果近邻的实例点刚好是噪声,预测就会出错。换句话说,$k$值的减小就意味着整体模型变得复杂,容易发生**过拟合**。 + +如果选择较大的$k$值,就相当于用较大的邻域中的训练实例进行预测,其优点是可以减少学习的估计误差,但缺点是学习的近似误差会增大。这时候,与输入实例较远(不相似的)训练实例也会对预测起作用,使预测发生错误。对于$k=N$的极端情况(其中$N$代表所有的训练实例的数量),那么无论输入实例是什么,都会预测它属于训练实例中最多的类,很显然,这样的模型完全忽略了训练实例中大量的有用信息,是不可取的。 + +实际应用中,$k$的取值通常都比较小,可以通过交叉检验的方式来选择较好的$k$值。 + + + +### 算法优缺点 + +优点: + +1. 简单有效 +2. 重新训练代价低 +3. 适合类域交叉样本 +4. 适合大样本分类 + +缺点: + +1. 惰性学习 +2. 输出的可解释性不强 +3. 不擅长处理不均衡样本 +4. 计算量比较大 \ No newline at end of file diff --git a/Day76-90/81.决策树.md b/Day71-85/73.决策树.md similarity index 100% rename from Day76-90/81.决策树.md rename to Day71-85/73.决策树.md diff --git a/Day76-90/82.贝叶斯分类.md b/Day71-85/74.贝叶斯分类.md similarity index 100% rename from Day76-90/82.贝叶斯分类.md rename to Day71-85/74.贝叶斯分类.md diff --git a/Day76-90/83.支持向量机.md b/Day71-85/75.支持向量机.md similarity index 100% rename from Day76-90/83.支持向量机.md rename to Day71-85/75.支持向量机.md diff --git a/Day76-90/84.K-均值聚类.md b/Day71-85/76.K-均值聚类.md similarity index 100% rename from Day76-90/84.K-均值聚类.md rename to Day71-85/76.K-均值聚类.md diff --git a/Day76-90/85.回归分析.md b/Day71-85/77.回归分析.md similarity index 100% rename from Day76-90/85.回归分析.md rename to Day71-85/77.回归分析.md diff --git a/Day76-90/88.Tensorflow入门.md b/Day71-85/78.深度学习入门.md similarity index 100% rename from Day76-90/88.Tensorflow入门.md rename to Day71-85/78.深度学习入门.md diff --git a/Day71-85/79.Tensorflow概述.md b/Day71-85/79.Tensorflow概述.md new file mode 100644 index 0000000..ade2f52 --- /dev/null +++ b/Day71-85/79.Tensorflow概述.md @@ -0,0 +1,2 @@ +## Tensorflow入门 + diff --git a/Day76-90/89.Tensorflow实战.md b/Day71-85/80.Tensorflow实战.md similarity index 100% rename from Day76-90/89.Tensorflow实战.md rename to Day71-85/80.Tensorflow实战.md diff --git a/Day71-85/81.Kaggle项目实战.md b/Day71-85/81.Kaggle项目实战.md new file mode 100644 index 0000000..3b2fe56 --- /dev/null +++ b/Day71-85/81.Kaggle项目实战.md @@ -0,0 +1,2 @@ +## Kaggle项目实战 + diff --git a/Day71-85/82.天池大数据项目实战.md b/Day71-85/82.天池大数据项目实战.md new file mode 100644 index 0000000..883b98e --- /dev/null +++ b/Day71-85/82.天池大数据项目实战.md @@ -0,0 +1,2 @@ +## 天池大数据项目实战 + diff --git a/Day71-85/83.推荐系统实战-1.md b/Day71-85/83.推荐系统实战-1.md new file mode 100644 index 0000000..55ca245 --- /dev/null +++ b/Day71-85/83.推荐系统实战-1.md @@ -0,0 +1,2 @@ +## 推荐系统实战(1) + diff --git a/Day71-85/84.推荐系统实战-2.md b/Day71-85/84.推荐系统实战-2.md new file mode 100644 index 0000000..47b5ac0 --- /dev/null +++ b/Day71-85/84.推荐系统实战-2.md @@ -0,0 +1,2 @@ +## 推荐系统实战(2) + diff --git a/Day71-85/85.推荐系统实战-3.md b/Day71-85/85.推荐系统实战-3.md new file mode 100644 index 0000000..3d28af5 --- /dev/null +++ b/Day71-85/85.推荐系统实战-3.md @@ -0,0 +1,2 @@ +## 推荐系统实战(3) + diff --git a/Day71-85/res/dajiang_robomaster.png b/Day71-85/res/dajiang_robomaster.png new file mode 100644 index 0000000..d65809c Binary files /dev/null and b/Day71-85/res/dajiang_robomaster.png differ diff --git a/Day71-85/res/face_paying.png b/Day71-85/res/face_paying.png new file mode 100644 index 0000000..66d619a Binary files /dev/null and b/Day71-85/res/face_paying.png differ diff --git a/Day71-85/res/quickdraw.png b/Day71-85/res/quickdraw.png new file mode 100644 index 0000000..463023f Binary files /dev/null and b/Day71-85/res/quickdraw.png differ diff --git a/Day71-85/res/scikit-learn-logo.png b/Day71-85/res/scikit-learn-logo.png new file mode 100644 index 0000000..c06a838 Binary files /dev/null and b/Day71-85/res/scikit-learn-logo.png differ diff --git a/Day71-85/res/sweep_robot.jpg b/Day71-85/res/sweep_robot.jpg new file mode 100644 index 0000000..bc2593f Binary files /dev/null and b/Day71-85/res/sweep_robot.jpg differ diff --git a/Day71-85/res/xiaomi_ai_voice_box.png b/Day71-85/res/xiaomi_ai_voice_box.png new file mode 100644 index 0000000..7f20777 Binary files /dev/null and b/Day71-85/res/xiaomi_ai_voice_box.png differ diff --git a/Day76-90/76.机器学习基础.md b/Day76-90/76.机器学习基础.md deleted file mode 100644 index b7a5941..0000000 --- a/Day76-90/76.机器学习基础.md +++ /dev/null @@ -1,33 +0,0 @@ -## 机器学习基础 - -所谓“机器学习”就是利用计算机将纷繁复杂的数据处理成有用的信息,这样就可以发掘出数据带来的意义以及隐藏在数据背后的规律。现如今,“机器学习”和“大数据”可以说是IT行业中最热点的两个词汇,而无论是“机器学习”还是“大数据”最终要解决的问题本质上是一样的,用最为直白的话来说就是用现有的数据去预测将来的状况。 - -按照问题的“输入”和“输出”,我们可以将用计算机解决的问题分为四大类: - -1. 输入的信息是精确的,要求输出最优解。 -2. 输入的信息是精确的,无法找到最优解。 -3. 输入的信息是模糊的,要求输出最优解。 -4. 输入的信息是模糊的,无法找到最优解。 - -在上面的四大类问题中,第1类问题是计算机最擅长解决的,这类问题其实就是“数值计算”和“逻辑推理”方面的问题,而传统意义上的人工智能也就是利用逻辑推理来解决问题(如早期的“人机对弈”)。一直以来,我们都习惯于将计算机称为“电脑”,而基于“冯诺依曼”体系结构的“电脑”实际上只是实现了“人脑”理性思维这部分的功能,而且在这一点上“电脑”通常是优于“人脑”的,而“人脑”在处理输入模糊信息时表现出来的强大的处理能力,在今天看来也不是“电脑”可以完全企及的。所以我们研究人工智能也好,研究机器学习也好,是希望输入模糊信息时,计算机能够给出满意的甚至是最优的答案。 - -至此,我们可以给“机器学习”下一个定义:机器学习是一门专门研究计算机怎样模拟或实现人类的学习行为,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身性能的学科。机器学习目前已经广泛的应用到生产生活的各个领域,以下列举了一些经典的场景: - -1. 搜索引擎:根据搜索和使用习惯,优化下一次搜索的结果。 -2. 电商网站:自动推荐你可能感兴趣的商品。 -3. 贷款申请:通过你最近的金融活动信息进行综合评定。 -4. 图像识别:自动识别图片中有没有不和谐的内容。 - -机器学习可以分为监督学习和非监督学习。监督学习是从给定的训练数据集中学习得到一个函数,当新的数据到来时,可以根据这个函数预测结果,监督学习的训练集包括输入和输出,也可以说是特征和目标。监督学习的目标是由人来标注的,而非监督学习的数据没有类别信息,训练集也没有人为标注结果,通过无监督学习可以减少数据特征的维度,以便我们可以使用二维或三维图形更加直观地展示数据信息 。 - -实现机器学习的一般步骤: - -1. 数据收集 -2. 数据准备 -3. 数据分析 -4. 训练算法 -5. 测试算法 -6. 应用算法 - - - diff --git a/Day76-90/78.NumPy和SciPy的应用.md b/Day76-90/78.NumPy和SciPy的应用.md deleted file mode 100644 index 6bc102f..0000000 --- a/Day76-90/78.NumPy和SciPy的应用.md +++ /dev/null @@ -1,2 +0,0 @@ -## NumPy和SciPy的应用 - diff --git a/Day76-90/80.k最近邻分类.md b/Day76-90/80.k最近邻分类.md deleted file mode 100644 index 918cf9c..0000000 --- a/Day76-90/80.k最近邻分类.md +++ /dev/null @@ -1,2 +0,0 @@ -## k最近邻分类 - diff --git a/Day76-90/86.大数据分析入门.md b/Day76-90/86.大数据分析入门.md deleted file mode 100644 index 988f860..0000000 --- a/Day76-90/86.大数据分析入门.md +++ /dev/null @@ -1,2 +0,0 @@ -## 大数据分析入门 - diff --git a/Day76-90/87.大数据分析进阶.md b/Day76-90/87.大数据分析进阶.md deleted file mode 100644 index e2b83b1..0000000 --- a/Day76-90/87.大数据分析进阶.md +++ /dev/null @@ -1,2 +0,0 @@ -## 大数据分析进阶 - diff --git a/Day76-90/90.推荐系统实战.md b/Day76-90/90.推荐系统实战.md deleted file mode 100644 index 77172df..0000000 --- a/Day76-90/90.推荐系统实战.md +++ /dev/null @@ -1,2 +0,0 @@ -## 推荐系统实战 - diff --git a/Day76-90/code/.ipynb_checkpoints/1-pandas入门-checkpoint.ipynb b/Day76-90/code/.ipynb_checkpoints/1-pandas入门-checkpoint.ipynb deleted file mode 100644 index b5b3acc..0000000 --- a/Day76-90/code/.ipynb_checkpoints/1-pandas入门-checkpoint.ipynb +++ /dev/null @@ -1,631 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Math 120\n", - "Python 136\n", - "En 128\n", - "Chinese 99\n", - "dtype: int64" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 创建\n", - "# Series是一维的数据\n", - "s = Series(data = [120,136,128,99],index = ['Math','Python','En','Chinese'])\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(4,)" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([120, 136, 128, 99], dtype=int64)" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "v = s.values\n", - "v" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "numpy.ndarray" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "type(v)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "120.75" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.mean()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "136" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.max()" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "15.903353943953666" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.std()" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Math 14400\n", - "Python 18496\n", - "En 16384\n", - "Chinese 9801\n", - "dtype: int64" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.pow(2)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          a11311675
          b1914523
          c57107113
          d95366
          e28121120
          f14185132
          h1243910
          i803517
          j689931
          k741211
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "a 113 116 75\n", - "b 19 145 23\n", - "c 57 107 113\n", - "d 95 3 66\n", - "e 28 121 120\n", - "f 141 85 132\n", - "h 124 39 10\n", - "i 80 35 17\n", - "j 68 99 31\n", - "k 74 12 11" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# DataFrame是二维的数据\n", - "# excel就非常相似\n", - "# 所有进行数据分析,数据挖掘的工具最基础的结果:行和列,行表示样本,列表示的是属性\n", - "df = DataFrame(data = np.random.randint(0,150,size = (10,3)),index = list('abcdefhijk'),columns=['Python','En','Math'])\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(10, 3)" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[113, 116, 75],\n", - " [ 19, 145, 23],\n", - " [ 57, 107, 113],\n", - " [ 95, 3, 66],\n", - " [ 28, 121, 120],\n", - " [141, 85, 132],\n", - " [124, 39, 10],\n", - " [ 80, 35, 17],\n", - " [ 68, 99, 31],\n", - " [ 74, 12, 11]])" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "v = df.values\n", - "v" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 79.9\n", - "En 76.2\n", - "Math 59.8\n", - "dtype: float64" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean()" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 141\n", - "En 145\n", - "Math 132\n", - "dtype: int32" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.max()" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          a11311675
          b1914523
          c57107113
          d95366
          e28121120
          f14185132
          h1243910
          i803517
          j689931
          k741211
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "a 113 116 75\n", - "b 19 145 23\n", - "c 57 107 113\n", - "d 95 3 66\n", - "e 28 121 120\n", - "f 141 85 132\n", - "h 124 39 10\n", - "i 80 35 17\n", - "j 68 99 31\n", - "k 74 12 11" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 79.9\n", - "En 76.2\n", - "Math 59.8\n", - "dtype: float64" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean(axis = 0)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "a 101.333333\n", - "b 62.333333\n", - "c 92.333333\n", - "d 54.666667\n", - "e 89.666667\n", - "f 119.333333\n", - "h 57.666667\n", - "i 44.000000\n", - "j 66.000000\n", - "k 32.333333\n", - "dtype: float64" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean(axis = 1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/1-pandas入门.ipynb b/Day76-90/code/1-pandas入门.ipynb deleted file mode 100644 index b5b3acc..0000000 --- a/Day76-90/code/1-pandas入门.ipynb +++ /dev/null @@ -1,631 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Math 120\n", - "Python 136\n", - "En 128\n", - "Chinese 99\n", - "dtype: int64" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 创建\n", - "# Series是一维的数据\n", - "s = Series(data = [120,136,128,99],index = ['Math','Python','En','Chinese'])\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(4,)" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([120, 136, 128, 99], dtype=int64)" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "v = s.values\n", - "v" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "numpy.ndarray" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "type(v)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "120.75" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.mean()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "136" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.max()" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "15.903353943953666" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.std()" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Math 14400\n", - "Python 18496\n", - "En 16384\n", - "Chinese 9801\n", - "dtype: int64" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.pow(2)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          a11311675
          b1914523
          c57107113
          d95366
          e28121120
          f14185132
          h1243910
          i803517
          j689931
          k741211
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "a 113 116 75\n", - "b 19 145 23\n", - "c 57 107 113\n", - "d 95 3 66\n", - "e 28 121 120\n", - "f 141 85 132\n", - "h 124 39 10\n", - "i 80 35 17\n", - "j 68 99 31\n", - "k 74 12 11" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# DataFrame是二维的数据\n", - "# excel就非常相似\n", - "# 所有进行数据分析,数据挖掘的工具最基础的结果:行和列,行表示样本,列表示的是属性\n", - "df = DataFrame(data = np.random.randint(0,150,size = (10,3)),index = list('abcdefhijk'),columns=['Python','En','Math'])\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(10, 3)" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[113, 116, 75],\n", - " [ 19, 145, 23],\n", - " [ 57, 107, 113],\n", - " [ 95, 3, 66],\n", - " [ 28, 121, 120],\n", - " [141, 85, 132],\n", - " [124, 39, 10],\n", - " [ 80, 35, 17],\n", - " [ 68, 99, 31],\n", - " [ 74, 12, 11]])" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "v = df.values\n", - "v" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 79.9\n", - "En 76.2\n", - "Math 59.8\n", - "dtype: float64" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean()" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 141\n", - "En 145\n", - "Math 132\n", - "dtype: int32" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.max()" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          a11311675
          b1914523
          c57107113
          d95366
          e28121120
          f14185132
          h1243910
          i803517
          j689931
          k741211
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "a 113 116 75\n", - "b 19 145 23\n", - "c 57 107 113\n", - "d 95 3 66\n", - "e 28 121 120\n", - "f 141 85 132\n", - "h 124 39 10\n", - "i 80 35 17\n", - "j 68 99 31\n", - "k 74 12 11" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 79.9\n", - "En 76.2\n", - "Math 59.8\n", - "dtype: float64" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean(axis = 0)" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "a 101.333333\n", - "b 62.333333\n", - "c 92.333333\n", - "d 54.666667\n", - "e 89.666667\n", - "f 119.333333\n", - "h 57.666667\n", - "i 44.000000\n", - "j 66.000000\n", - "k 32.333333\n", - "dtype: float64" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean(axis = 1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/2-pandas-索引.ipynb b/Day76-90/code/2-pandas-索引.ipynb deleted file mode 100644 index ddbde0a..0000000 --- a/Day76-90/code/2-pandas-索引.ipynb +++ /dev/null @@ -1,2082 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "11 111\n", - "12 113\n", - "13 103\n", - "14 147\n", - "15 63\n", - "16 11\n", - "17 130\n", - "18 38\n", - "19 17\n", - "20 32\n", - "21 112\n", - "22 75\n", - "23 68\n", - "24 124\n", - "25 138\n", - "26 56\n", - "27 1\n", - "28 88\n", - "29 113\n", - "30 63\n", - "31 42\n", - "32 65\n", - "33 104\n", - "34 105\n", - "35 0\n", - "36 95\n", - "37 119\n", - "38 86\n", - "39 124\n", - " ... \n", - "80 127\n", - "81 139\n", - "82 110\n", - "83 65\n", - "84 127\n", - "85 108\n", - "86 33\n", - "87 91\n", - "88 134\n", - "89 65\n", - "90 110\n", - "91 144\n", - "92 40\n", - "93 3\n", - "94 3\n", - "95 59\n", - "96 97\n", - "97 64\n", - "98 126\n", - "99 94\n", - "100 20\n", - "101 107\n", - "102 59\n", - "103 146\n", - "104 83\n", - "105 59\n", - "106 25\n", - "107 0\n", - "108 78\n", - "109 93\n", - "Name: Python, Length: 100, dtype: int16" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s = Series(np.random.randint(0,150,size = 100),index = np.arange(10,110),dtype=np.int16,name = 'Python')\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "ename": "KeyError", - "evalue": "0", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[1;31m# 索引操作\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0ms\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\series.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 866\u001b[0m \u001b[0mkey\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_if_callable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 867\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 868\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_value\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 869\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 870\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mis_scalar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_value\u001b[1;34m(self, series, key)\u001b[0m\n\u001b[0;32m 4373\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4374\u001b[0m return self._engine.get_value(s, k,\n\u001b[1;32m-> 4375\u001b[1;33m tz=getattr(series.dtype, 'tz', None))\n\u001b[0m\u001b[0;32m 4376\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4377\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mholds_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_boolean\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_value\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_value\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.Int64HashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.Int64HashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;31mKeyError\u001b[0m: 0" - ] - } - ], - "source": [ - "# 索引操作\n", - "s[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "34" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s[10]" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "20 32\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s[[10,20]]" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "20 32\n", - "21 112\n", - "22 75\n", - "23 68\n", - "24 124\n", - "25 138\n", - "26 56\n", - "27 1\n", - "28 88\n", - "29 113\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 切片操作\n", - "s[10:20]" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "12 113\n", - "14 147\n", - "16 11\n", - "18 38\n", - "20 32\n", - "22 75\n", - "24 124\n", - "26 56\n", - "28 88\n", - "30 63\n", - "32 65\n", - "34 105\n", - "36 95\n", - "38 86\n", - "40 6\n", - "42 57\n", - "44 72\n", - "46 43\n", - "48 87\n", - "50 83\n", - "52 99\n", - "54 132\n", - "56 17\n", - "58 116\n", - "60 33\n", - "62 51\n", - "64 80\n", - "66 121\n", - "68 81\n", - "70 0\n", - "72 50\n", - "74 31\n", - "76 114\n", - "78 60\n", - "80 127\n", - "82 110\n", - "84 127\n", - "86 33\n", - "88 134\n", - "90 110\n", - "92 40\n", - "94 3\n", - "96 97\n", - "98 126\n", - "100 20\n", - "102 59\n", - "104 83\n", - "106 25\n", - "108 78\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s[::2]" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "109 93\n", - "107 0\n", - "105 59\n", - "103 146\n", - "101 107\n", - "99 94\n", - "97 64\n", - "95 59\n", - "93 3\n", - "91 144\n", - "89 65\n", - "87 91\n", - "85 108\n", - "83 65\n", - "81 139\n", - "79 14\n", - "77 96\n", - "75 76\n", - "73 29\n", - "71 68\n", - "69 4\n", - "67 57\n", - "65 58\n", - "63 106\n", - "61 42\n", - "59 135\n", - "57 56\n", - "55 12\n", - "53 135\n", - "51 74\n", - "49 129\n", - "47 110\n", - "45 1\n", - "43 90\n", - "41 120\n", - "39 124\n", - "37 119\n", - "35 0\n", - "33 104\n", - "31 42\n", - "29 113\n", - "27 1\n", - "25 138\n", - "23 68\n", - "21 112\n", - "19 17\n", - "17 130\n", - "15 63\n", - "13 103\n", - "11 111\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s[::-2]" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "34" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 可以使用pandas为开发者提供方法,去进行检索\n", - "s.loc[10]" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "20 32\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.loc[[10,20]]" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "11 111\n", - "12 113\n", - "13 103\n", - "14 147\n", - "15 63\n", - "16 11\n", - "17 130\n", - "18 38\n", - "19 17\n", - "20 32\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.loc[10:20]" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "12 113\n", - "14 147\n", - "16 11\n", - "18 38\n", - "20 32\n", - "22 75\n", - "24 124\n", - "26 56\n", - "28 88\n", - "30 63\n", - "32 65\n", - "34 105\n", - "36 95\n", - "38 86\n", - "40 6\n", - "42 57\n", - "44 72\n", - "46 43\n", - "48 87\n", - "50 83\n", - "52 99\n", - "54 132\n", - "56 17\n", - "58 116\n", - "60 33\n", - "62 51\n", - "64 80\n", - "66 121\n", - "68 81\n", - "70 0\n", - "72 50\n", - "74 31\n", - "76 114\n", - "78 60\n", - "80 127\n", - "82 110\n", - "84 127\n", - "86 33\n", - "88 134\n", - "90 110\n", - "92 40\n", - "94 3\n", - "96 97\n", - "98 126\n", - "100 20\n", - "102 59\n", - "104 83\n", - "106 25\n", - "108 78\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.loc[::2]" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "109 93\n", - "107 0\n", - "105 59\n", - "103 146\n", - "101 107\n", - "99 94\n", - "97 64\n", - "95 59\n", - "93 3\n", - "91 144\n", - "89 65\n", - "87 91\n", - "85 108\n", - "83 65\n", - "81 139\n", - "79 14\n", - "77 96\n", - "75 76\n", - "73 29\n", - "71 68\n", - "69 4\n", - "67 57\n", - "65 58\n", - "63 106\n", - "61 42\n", - "59 135\n", - "57 56\n", - "55 12\n", - "53 135\n", - "51 74\n", - "49 129\n", - "47 110\n", - "45 1\n", - "43 90\n", - "41 120\n", - "39 124\n", - "37 119\n", - "35 0\n", - "33 104\n", - "31 42\n", - "29 113\n", - "27 1\n", - "25 138\n", - "23 68\n", - "21 112\n", - "19 17\n", - "17 130\n", - "15 63\n", - "13 103\n", - "11 111\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.loc[::-2]" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Int64Index([ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\n", - " 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n", - " 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,\n", - " 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n", - " 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,\n", - " 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,\n", - " 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,\n", - " 101, 102, 103, 104, 105, 106, 107, 108, 109],\n", - " dtype='int64')" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.index" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "34" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# iloc 索引从0开始,数字化自然索引\n", - "s.iloc[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "20 32\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.iloc[[0,10]]" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "10 34\n", - "11 111\n", - "12 113\n", - "13 103\n", - "14 147\n", - "15 63\n", - "16 11\n", - "17 130\n", - "18 38\n", - "19 17\n", - "20 32\n", - "21 112\n", - "22 75\n", - "23 68\n", - "24 124\n", - "25 138\n", - "26 56\n", - "27 1\n", - "28 88\n", - "29 113\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.iloc[0:20]" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "109 93\n", - "107 0\n", - "105 59\n", - "103 146\n", - "101 107\n", - "99 94\n", - "97 64\n", - "95 59\n", - "93 3\n", - "91 144\n", - "89 65\n", - "87 91\n", - "85 108\n", - "83 65\n", - "81 139\n", - "79 14\n", - "77 96\n", - "75 76\n", - "73 29\n", - "71 68\n", - "69 4\n", - "67 57\n", - "65 58\n", - "63 106\n", - "61 42\n", - "59 135\n", - "57 56\n", - "55 12\n", - "53 135\n", - "51 74\n", - "49 129\n", - "47 110\n", - "45 1\n", - "43 90\n", - "41 120\n", - "39 124\n", - "37 119\n", - "35 0\n", - "33 104\n", - "31 42\n", - "29 113\n", - "27 1\n", - "25 138\n", - "23 68\n", - "21 112\n", - "19 17\n", - "17 130\n", - "15 63\n", - "13 103\n", - "11 111\n", - "Name: Python, dtype: int16" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s.iloc[::-2]" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          B13565135
          C1379146
          D4724145
          E899716
          F6426109
          H4846111
          I164997
          J122126100
          K6013662
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "B 135 65 135\n", - "C 13 79 146\n", - "D 47 24 145\n", - "E 89 97 16\n", - "F 64 26 109\n", - "H 48 46 111\n", - "I 16 49 97\n", - "J 122 126 100\n", - "K 60 136 62" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# DataFrame是二维,索引大同小异,\n", - "df = DataFrame(data = np.random.randint(0,150,size= (10,3)),index=list('ABCDEFHIJK'),columns=['Python','En','Math'])\n", - "\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'A'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2656\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2657\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2658\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;31mKeyError\u001b[0m: 'A'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'A'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 2925\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2926\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2927\u001b[1;33m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2928\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2929\u001b[0m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2657\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2658\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2659\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2660\u001b[0m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2661\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msize\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;31mKeyError\u001b[0m: 'A'" - ] - } - ], - "source": [ - "df['A']" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "A 103\n", - "B 135\n", - "C 13\n", - "D 47\n", - "E 89\n", - "F 64\n", - "H 48\n", - "I 16\n", - "J 122\n", - "K 60\n", - "Name: Python, dtype: int32" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df['Python']" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEn
          A10356
          B13565
          C1379
          D4724
          E8997
          F6426
          H4846
          I1649
          J122126
          K60136
          \n", - "
          " - ], - "text/plain": [ - " Python En\n", - "A 103 56\n", - "B 135 65\n", - "C 13 79\n", - "D 47 24\n", - "E 89 97\n", - "F 64 26\n", - "H 48 46\n", - "I 16 49\n", - "J 122 126\n", - "K 60 136" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df[['Python','En']]" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          \n", - "
          " - ], - "text/plain": [ - "Empty DataFrame\n", - "Columns: [Python, En, Math]\n", - "Index: []" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df['Python':'Math']" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          B13565135
          C1379146
          D4724145
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "B 135 65 135\n", - "C 13 79 146\n", - "D 47 24 145" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df['A':'D']" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'Python'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2656\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2657\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2658\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;31mKeyError\u001b[0m: 'Python'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'Python'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 1498\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1499\u001b[0m \u001b[0mmaybe_callable\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_if_callable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1500\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmaybe_callable\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1501\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1502\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_is_scalar_access\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_axis\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m 1911\u001b[0m \u001b[1;31m# fall thru to straight lookup\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1912\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_validate_key\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1913\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_label\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1914\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1915\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_get_label\u001b[1;34m(self, label, axis)\u001b[0m\n\u001b[0;32m 139\u001b[0m \u001b[1;32mraise\u001b[0m \u001b[0mIndexingError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'no slices here, handle elsewhere'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 140\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 141\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_xs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlabel\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 142\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 143\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_get_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mxs\u001b[1;34m(self, key, axis, level, drop_level)\u001b[0m\n\u001b[0;32m 3583\u001b[0m drop_level=drop_level)\n\u001b[0;32m 3584\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3585\u001b[1;33m \u001b[0mloc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 3586\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3587\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m 2657\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2658\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2659\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2660\u001b[0m \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2661\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msize\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n", - "\u001b[1;31mKeyError\u001b[0m: 'Python'" - ] - } - ], - "source": [ - "df.loc['Python']" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 103\n", - "En 56\n", - "Math 98\n", - "Name: A, dtype: int32" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.loc['A']" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          H4846111
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "H 48 46 111" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.loc[['A','H']]" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          B13565135
          C1379146
          D4724145
          E899716
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "B 135 65 135\n", - "C 13 79 146\n", - "D 47 24 145\n", - "E 89 97 16" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.loc['A':'E']" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          C1379146
          E899716
          H4846111
          J122126100
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "C 13 79 146\n", - "E 89 97 16\n", - "H 48 46 111\n", - "J 122 126 100" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.loc[::2]" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          K6013662
          I164997
          F6426109
          D4724145
          B13565135
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "K 60 136 62\n", - "I 16 49 97\n", - "F 64 26 109\n", - "D 47 24 145\n", - "B 135 65 135" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.loc[::-2]" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "ename": "TypeError", - "evalue": "Cannot index by location index with a non-integer key", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0miloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'A'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m 1498\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1499\u001b[0m \u001b[0mmaybe_callable\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mapply_if_callable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1500\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmaybe_callable\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1501\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1502\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0m_is_scalar_access\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32md:\\python36\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_getitem_axis\u001b[1;34m(self, key, axis)\u001b[0m\n\u001b[0;32m 2224\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2225\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2226\u001b[1;33m raise TypeError(\"Cannot index by location index with a \"\n\u001b[0m\u001b[0;32m 2227\u001b[0m \"non-integer key\")\n\u001b[0;32m 2228\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mTypeError\u001b[0m: Cannot index by location index with a non-integer key" - ] - } - ], - "source": [ - "df.iloc['A']" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 103\n", - "En 56\n", - "Math 98\n", - "Name: A, dtype: int32" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          F6426109
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "F 64 26 109" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[[0,5]]" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          B13565135
          C1379146
          D4724145
          E899716
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "B 135 65 135\n", - "C 13 79 146\n", - "D 47 24 145\n", - "E 89 97 16" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[0:5]" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          K6013662
          I164997
          F6426109
          D4724145
          B13565135
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "K 60 136 62\n", - "I 16 49 97\n", - "F 64 26 109\n", - "D 47 24 145\n", - "B 135 65 135" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[::-2]" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A1035698
          B13565135
          C1379146
          D4724145
          E899716
          F6426109
          H4846111
          I164997
          J122126100
          K6013662
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 103 56 98\n", - "B 135 65 135\n", - "C 13 79 146\n", - "D 47 24 145\n", - "E 89 97 16\n", - "F 64 26 109\n", - "H 48 46 111\n", - "I 16 49 97\n", - "J 122 126 100\n", - "K 60 136 62" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          EnMath
          A5698
          C79146
          E9716
          H46111
          J126100
          \n", - "
          " - ], - "text/plain": [ - " En Math\n", - "A 56 98\n", - "C 79 146\n", - "E 97 16\n", - "H 46 111\n", - "J 126 100" - ] - }, - "execution_count": 40, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[::2,1:]" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/3-pandas数据清洗之空数据.ipynb b/Day76-90/code/3-pandas数据清洗之空数据.ipynb deleted file mode 100644 index dde9ec6..0000000 --- a/Day76-90/code/3-pandas数据清洗之空数据.ipynb +++ /dev/null @@ -1,6285 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          1001221052857
          101741291611426
          102971211222965
          103141731201471
          1041261328611617
          1058534212166
          10614265112483
          10713614112286113
          1081537124110102
          1096330446958
          110593811310916
          1115518758126
          1125397763745
          1134214810797143
          114701386968134
          115471361132294
          1163113762028
          117148741344124
          1181028113812832
          11927111137022
          1202893121684
          12113643259719
          12211170123858
          12396103147868
          12410104663149
          1257759710831
          12688614511655
          12733741065046
          12874282610076
          1297618101126133
          ..................
          170144124779282
          1713698484380
          17251143683474
          17314911718141120
          1748139146112122
          17511510164629
          17610714045148
          17765436810918
          1783110011049123
          1792946695790
          18014686182246
          18171504090140
          1824100147116110
          1835587937834
          18451091248782
          185101181395051
          18632127136124
          187941613813149
          1886510112312886
          18943941029132
          190681359428125
          1913060982715
          1928916101354
          193104139972917
          194529419991
          195191021354140
          19658100708264
          19784971297613
          19813115744114
          199793795128116
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122 10 5 28 57\n", - "101 74 129 16 114 26\n", - "102 97 121 122 29 65\n", - "103 141 73 120 147 1\n", - "104 126 132 86 116 17\n", - "105 85 3 42 121 66\n", - "106 142 65 1 124 83\n", - "107 136 141 122 86 113\n", - "108 15 37 124 110 102\n", - "109 63 30 44 69 58\n", - "110 59 38 113 109 16\n", - "111 5 51 87 58 126\n", - "112 53 97 76 37 45\n", - "113 42 148 107 97 143\n", - "114 70 138 69 68 134\n", - "115 47 136 113 22 94\n", - "116 31 137 6 20 28\n", - "117 148 74 134 4 124\n", - "118 102 81 138 128 32\n", - "119 27 111 13 70 22\n", - "120 28 93 121 68 4\n", - "121 136 43 25 97 19\n", - "122 111 70 12 38 58\n", - "123 96 103 147 86 8\n", - "124 10 10 46 63 149\n", - "125 7 75 97 108 31\n", - "126 88 6 145 116 55\n", - "127 33 74 106 50 46\n", - "128 74 28 26 100 76\n", - "129 76 18 101 126 133\n", - ".. ... ... ... ... ...\n", - "170 144 124 77 92 82\n", - "171 36 98 48 43 80\n", - "172 51 143 68 34 74\n", - "173 149 117 18 141 120\n", - "174 8 139 146 112 122\n", - "175 115 101 64 62 9\n", - "176 10 7 140 45 148\n", - "177 65 43 68 109 18\n", - "178 31 100 110 49 123\n", - "179 29 46 69 57 90\n", - "180 146 86 18 22 46\n", - "181 71 50 40 90 140\n", - "182 4 100 147 116 110\n", - "183 55 87 93 78 34\n", - "184 5 109 124 87 82\n", - "185 10 118 139 50 51\n", - "186 32 12 71 36 124\n", - "187 94 16 138 13 149\n", - "188 65 101 123 128 86\n", - "189 43 94 10 29 132\n", - "190 68 135 94 28 125\n", - "191 30 60 98 27 15\n", - "192 89 16 10 135 4\n", - "193 104 139 97 29 17\n", - "194 5 29 41 99 91\n", - "195 19 102 135 41 40\n", - "196 58 100 70 82 64\n", - "197 84 97 129 76 13\n", - "198 131 15 7 44 114\n", - "199 79 37 95 128 116\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = DataFrame(np.random.randint(0,150,size = (100,5)),index = np.arange(100,200),columns=['Python','En','Math','Physic','Chem'])\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python False\n", - "En False\n", - "Math False\n", - "Physic False\n", - "Chem False\n", - "dtype: bool" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 判断DataFrame是否存在空数据\n", - "df.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python True\n", - "En True\n", - "Math True\n", - "Physic True\n", - "Chem True\n", - "dtype: bool" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.notnull().all()" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "500" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "100*5" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(50):\n", - " # 行索引\n", - " index = np.random.randint(100,200,size =1)[0]\n", - "\n", - " cols = df.columns\n", - "\n", - " # 列索引\n", - " col = np.random.choice(cols)\n", - "\n", - " df.loc[index,col] = None" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(20):\n", - " # 行索引\n", - " index = np.random.randint(100,200,size =1)[0]\n", - "\n", - " cols = df.columns\n", - "\n", - " # 列索引\n", - " col = np.random.choice(cols)\n", - "\n", - "# not a number 不是一个数\n", - " df.loc[index,col] = np.NAN" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          100122.010.05.028.057.0
          101NaN129.016.0114.026.0
          10297.0121.0122.029.065.0
          103141.073.0120.0147.01.0
          104126.0NaN86.0116.017.0
          10585.0NaN42.0121.066.0
          106142.065.01.0124.083.0
          107136.0141.0NaN86.0113.0
          10815.037.0124.0110.0102.0
          10963.030.0NaN69.058.0
          110NaNNaN113.0109.016.0
          1115.051.087.058.0126.0
          11253.097.076.037.045.0
          11342.0148.0NaN97.0NaN
          11470.0138.069.068.0134.0
          115NaN136.0113.022.094.0
          11631.0137.06.020.028.0
          117148.074.0134.04.0124.0
          118102.081.0138.0128.032.0
          11927.0111.013.0NaN22.0
          12028.093.0121.0NaN4.0
          121136.0NaN25.097.019.0
          122111.070.012.038.058.0
          123NaN103.0147.086.08.0
          12410.010.046.063.0149.0
          1257.075.097.0108.031.0
          12688.06.0NaNNaN55.0
          12733.074.0106.050.046.0
          12874.028.026.0100.076.0
          12976.018.0101.0NaNNaN
          ..................
          170144.0124.077.092.082.0
          17136.098.0NaN43.080.0
          17251.0NaN68.034.074.0
          173149.0NaN18.0141.0NaN
          1748.0139.0146.0112.0NaN
          175115.0NaN64.062.09.0
          176NaN7.0140.045.0148.0
          177NaN43.068.0109.018.0
          17831.0100.0NaN49.0123.0
          17929.046.069.057.090.0
          180146.086.018.022.046.0
          18171.050.040.0NaN140.0
          1824.0100.0147.0116.0110.0
          18355.087.093.0NaN34.0
          184NaN109.0124.087.082.0
          18510.0118.0139.050.051.0
          18632.012.071.036.0NaN
          18794.0NaN138.013.0149.0
          18865.0101.0123.0128.086.0
          18943.094.0NaN29.0132.0
          19068.0135.094.028.0125.0
          19130.060.098.0NaN15.0
          19289.016.010.0135.04.0
          193104.0139.097.029.017.0
          1945.029.041.099.0NaN
          19519.0102.0135.041.040.0
          19658.0NaN70.082.064.0
          197NaN97.0129.076.013.0
          198131.015.0NaN44.0114.0
          19979.0NaN95.0128.0NaN
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122.0 10.0 5.0 28.0 57.0\n", - "101 NaN 129.0 16.0 114.0 26.0\n", - "102 97.0 121.0 122.0 29.0 65.0\n", - "103 141.0 73.0 120.0 147.0 1.0\n", - "104 126.0 NaN 86.0 116.0 17.0\n", - "105 85.0 NaN 42.0 121.0 66.0\n", - "106 142.0 65.0 1.0 124.0 83.0\n", - "107 136.0 141.0 NaN 86.0 113.0\n", - "108 15.0 37.0 124.0 110.0 102.0\n", - "109 63.0 30.0 NaN 69.0 58.0\n", - "110 NaN NaN 113.0 109.0 16.0\n", - "111 5.0 51.0 87.0 58.0 126.0\n", - "112 53.0 97.0 76.0 37.0 45.0\n", - "113 42.0 148.0 NaN 97.0 NaN\n", - "114 70.0 138.0 69.0 68.0 134.0\n", - "115 NaN 136.0 113.0 22.0 94.0\n", - "116 31.0 137.0 6.0 20.0 28.0\n", - "117 148.0 74.0 134.0 4.0 124.0\n", - "118 102.0 81.0 138.0 128.0 32.0\n", - "119 27.0 111.0 13.0 NaN 22.0\n", - "120 28.0 93.0 121.0 NaN 4.0\n", - "121 136.0 NaN 25.0 97.0 19.0\n", - "122 111.0 70.0 12.0 38.0 58.0\n", - "123 NaN 103.0 147.0 86.0 8.0\n", - "124 10.0 10.0 46.0 63.0 149.0\n", - "125 7.0 75.0 97.0 108.0 31.0\n", - "126 88.0 6.0 NaN NaN 55.0\n", - "127 33.0 74.0 106.0 50.0 46.0\n", - "128 74.0 28.0 26.0 100.0 76.0\n", - "129 76.0 18.0 101.0 NaN NaN\n", - ".. ... ... ... ... ...\n", - "170 144.0 124.0 77.0 92.0 82.0\n", - "171 36.0 98.0 NaN 43.0 80.0\n", - "172 51.0 NaN 68.0 34.0 74.0\n", - "173 149.0 NaN 18.0 141.0 NaN\n", - "174 8.0 139.0 146.0 112.0 NaN\n", - "175 115.0 NaN 64.0 62.0 9.0\n", - "176 NaN 7.0 140.0 45.0 148.0\n", - "177 NaN 43.0 68.0 109.0 18.0\n", - "178 31.0 100.0 NaN 49.0 123.0\n", - "179 29.0 46.0 69.0 57.0 90.0\n", - "180 146.0 86.0 18.0 22.0 46.0\n", - "181 71.0 50.0 40.0 NaN 140.0\n", - "182 4.0 100.0 147.0 116.0 110.0\n", - "183 55.0 87.0 93.0 NaN 34.0\n", - "184 NaN 109.0 124.0 87.0 82.0\n", - "185 10.0 118.0 139.0 50.0 51.0\n", - "186 32.0 12.0 71.0 36.0 NaN\n", - "187 94.0 NaN 138.0 13.0 149.0\n", - "188 65.0 101.0 123.0 128.0 86.0\n", - "189 43.0 94.0 NaN 29.0 132.0\n", - "190 68.0 135.0 94.0 28.0 125.0\n", - "191 30.0 60.0 98.0 NaN 15.0\n", - "192 89.0 16.0 10.0 135.0 4.0\n", - "193 104.0 139.0 97.0 29.0 17.0\n", - "194 5.0 29.0 41.0 99.0 NaN\n", - "195 19.0 102.0 135.0 41.0 40.0\n", - "196 58.0 NaN 70.0 82.0 64.0\n", - "197 NaN 97.0 129.0 76.0 13.0\n", - "198 131.0 15.0 NaN 44.0 114.0\n", - "199 79.0 NaN 95.0 128.0 NaN\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python True\n", - "En True\n", - "Math True\n", - "Physic True\n", - "Chem True\n", - "dtype: bool" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 14\n", - "En 14\n", - "Math 15\n", - "Physic 11\n", - "Chem 13\n", - "dtype: int64" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.isnull().sum()" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "df2 = df.copy()" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 14\n", - "En 14\n", - "Math 15\n", - "Physic 11\n", - "Chem 13\n", - "dtype: int64" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2.isnull().sum()" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          100122.010.05.028.057.0
          101100.0129.016.0114.026.0
          10297.0121.0122.029.065.0
          103141.073.0120.0147.01.0
          104126.0100.086.0116.017.0
          10585.0100.042.0121.066.0
          106142.065.01.0124.083.0
          107136.0141.0100.086.0113.0
          10815.037.0124.0110.0102.0
          10963.030.0100.069.058.0
          110100.0100.0113.0109.016.0
          1115.051.087.058.0126.0
          11253.097.076.037.045.0
          11342.0148.0100.097.0100.0
          11470.0138.069.068.0134.0
          115100.0136.0113.022.094.0
          11631.0137.06.020.028.0
          117148.074.0134.04.0124.0
          118102.081.0138.0128.032.0
          11927.0111.013.0100.022.0
          12028.093.0121.0100.04.0
          121136.0100.025.097.019.0
          122111.070.012.038.058.0
          123100.0103.0147.086.08.0
          12410.010.046.063.0149.0
          1257.075.097.0108.031.0
          12688.06.0100.0100.055.0
          12733.074.0106.050.046.0
          12874.028.026.0100.076.0
          12976.018.0101.0100.0100.0
          ..................
          170144.0124.077.092.082.0
          17136.098.0100.043.080.0
          17251.0100.068.034.074.0
          173149.0100.018.0141.0100.0
          1748.0139.0146.0112.0100.0
          175115.0100.064.062.09.0
          176100.07.0140.045.0148.0
          177100.043.068.0109.018.0
          17831.0100.0100.049.0123.0
          17929.046.069.057.090.0
          180146.086.018.022.046.0
          18171.050.040.0100.0140.0
          1824.0100.0147.0116.0110.0
          18355.087.093.0100.034.0
          184100.0109.0124.087.082.0
          18510.0118.0139.050.051.0
          18632.012.071.036.0100.0
          18794.0100.0138.013.0149.0
          18865.0101.0123.0128.086.0
          18943.094.0100.029.0132.0
          19068.0135.094.028.0125.0
          19130.060.098.0100.015.0
          19289.016.010.0135.04.0
          193104.0139.097.029.017.0
          1945.029.041.099.0100.0
          19519.0102.0135.041.040.0
          19658.0100.070.082.064.0
          197100.097.0129.076.013.0
          198131.015.0100.044.0114.0
          19979.0100.095.0128.0100.0
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122.0 10.0 5.0 28.0 57.0\n", - "101 100.0 129.0 16.0 114.0 26.0\n", - "102 97.0 121.0 122.0 29.0 65.0\n", - "103 141.0 73.0 120.0 147.0 1.0\n", - "104 126.0 100.0 86.0 116.0 17.0\n", - "105 85.0 100.0 42.0 121.0 66.0\n", - "106 142.0 65.0 1.0 124.0 83.0\n", - "107 136.0 141.0 100.0 86.0 113.0\n", - "108 15.0 37.0 124.0 110.0 102.0\n", - "109 63.0 30.0 100.0 69.0 58.0\n", - "110 100.0 100.0 113.0 109.0 16.0\n", - "111 5.0 51.0 87.0 58.0 126.0\n", - "112 53.0 97.0 76.0 37.0 45.0\n", - "113 42.0 148.0 100.0 97.0 100.0\n", - "114 70.0 138.0 69.0 68.0 134.0\n", - "115 100.0 136.0 113.0 22.0 94.0\n", - "116 31.0 137.0 6.0 20.0 28.0\n", - "117 148.0 74.0 134.0 4.0 124.0\n", - "118 102.0 81.0 138.0 128.0 32.0\n", - "119 27.0 111.0 13.0 100.0 22.0\n", - "120 28.0 93.0 121.0 100.0 4.0\n", - "121 136.0 100.0 25.0 97.0 19.0\n", - "122 111.0 70.0 12.0 38.0 58.0\n", - "123 100.0 103.0 147.0 86.0 8.0\n", - "124 10.0 10.0 46.0 63.0 149.0\n", - "125 7.0 75.0 97.0 108.0 31.0\n", - "126 88.0 6.0 100.0 100.0 55.0\n", - "127 33.0 74.0 106.0 50.0 46.0\n", - "128 74.0 28.0 26.0 100.0 76.0\n", - "129 76.0 18.0 101.0 100.0 100.0\n", - ".. ... ... ... ... ...\n", - "170 144.0 124.0 77.0 92.0 82.0\n", - "171 36.0 98.0 100.0 43.0 80.0\n", - "172 51.0 100.0 68.0 34.0 74.0\n", - "173 149.0 100.0 18.0 141.0 100.0\n", - "174 8.0 139.0 146.0 112.0 100.0\n", - "175 115.0 100.0 64.0 62.0 9.0\n", - "176 100.0 7.0 140.0 45.0 148.0\n", - "177 100.0 43.0 68.0 109.0 18.0\n", - "178 31.0 100.0 100.0 49.0 123.0\n", - "179 29.0 46.0 69.0 57.0 90.0\n", - "180 146.0 86.0 18.0 22.0 46.0\n", - "181 71.0 50.0 40.0 100.0 140.0\n", - "182 4.0 100.0 147.0 116.0 110.0\n", - "183 55.0 87.0 93.0 100.0 34.0\n", - "184 100.0 109.0 124.0 87.0 82.0\n", - "185 10.0 118.0 139.0 50.0 51.0\n", - "186 32.0 12.0 71.0 36.0 100.0\n", - "187 94.0 100.0 138.0 13.0 149.0\n", - "188 65.0 101.0 123.0 128.0 86.0\n", - "189 43.0 94.0 100.0 29.0 132.0\n", - "190 68.0 135.0 94.0 28.0 125.0\n", - "191 30.0 60.0 98.0 100.0 15.0\n", - "192 89.0 16.0 10.0 135.0 4.0\n", - "193 104.0 139.0 97.0 29.0 17.0\n", - "194 5.0 29.0 41.0 99.0 100.0\n", - "195 19.0 102.0 135.0 41.0 40.0\n", - "196 58.0 100.0 70.0 82.0 64.0\n", - "197 100.0 97.0 129.0 76.0 13.0\n", - "198 131.0 15.0 100.0 44.0 114.0\n", - "199 79.0 100.0 95.0 128.0 100.0\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 固定值填充\n", - "df2.fillna(value=100)" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 71.662791\n", - "En 75.627907\n", - "Math 77.929412\n", - "Physic 73.471910\n", - "Chem 69.080460\n", - "dtype: float64" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2.mean()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          1001221052857
          101711291611426
          102971211222965
          103141731201471
          104126758611617
          10585754212166
          10614265112483
          1071361417786113
          1081537124110102
          1096330776958
          110717511310916
          1115518758126
          1125397763745
          11342148779769
          114701386968134
          115711361132294
          1163113762028
          117148741344124
          1181028113812832
          11927111137322
          1202893121734
          12113675259719
          12211170123858
          12371103147868
          12410104663149
          1257759710831
          126886777355
          12733741065046
          12874282610076
          12976181017369
          ..................
          170144124779282
          1713698774380
          1725175683474
          173149751814169
          174813914611269
          1751157564629
          17671714045148
          17771436810918
          178311007749123
          1792946695790
          18014686182246
          18171504073140
          1824100147116110
          1835587937334
          184711091248782
          185101181395051
          1863212713669
          187947513813149
          1886510112312886
          18943947729132
          190681359428125
          1913060987315
          1928916101354
          193104139972917
          194529419969
          195191021354140
          1965875708264
          19771971297613
          198131157744114
          19979759512869
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122 10 5 28 57\n", - "101 71 129 16 114 26\n", - "102 97 121 122 29 65\n", - "103 141 73 120 147 1\n", - "104 126 75 86 116 17\n", - "105 85 75 42 121 66\n", - "106 142 65 1 124 83\n", - "107 136 141 77 86 113\n", - "108 15 37 124 110 102\n", - "109 63 30 77 69 58\n", - "110 71 75 113 109 16\n", - "111 5 51 87 58 126\n", - "112 53 97 76 37 45\n", - "113 42 148 77 97 69\n", - "114 70 138 69 68 134\n", - "115 71 136 113 22 94\n", - "116 31 137 6 20 28\n", - "117 148 74 134 4 124\n", - "118 102 81 138 128 32\n", - "119 27 111 13 73 22\n", - "120 28 93 121 73 4\n", - "121 136 75 25 97 19\n", - "122 111 70 12 38 58\n", - "123 71 103 147 86 8\n", - "124 10 10 46 63 149\n", - "125 7 75 97 108 31\n", - "126 88 6 77 73 55\n", - "127 33 74 106 50 46\n", - "128 74 28 26 100 76\n", - "129 76 18 101 73 69\n", - ".. ... ... ... ... ...\n", - "170 144 124 77 92 82\n", - "171 36 98 77 43 80\n", - "172 51 75 68 34 74\n", - "173 149 75 18 141 69\n", - "174 8 139 146 112 69\n", - "175 115 75 64 62 9\n", - "176 71 7 140 45 148\n", - "177 71 43 68 109 18\n", - "178 31 100 77 49 123\n", - "179 29 46 69 57 90\n", - "180 146 86 18 22 46\n", - "181 71 50 40 73 140\n", - "182 4 100 147 116 110\n", - "183 55 87 93 73 34\n", - "184 71 109 124 87 82\n", - "185 10 118 139 50 51\n", - "186 32 12 71 36 69\n", - "187 94 75 138 13 149\n", - "188 65 101 123 128 86\n", - "189 43 94 77 29 132\n", - "190 68 135 94 28 125\n", - "191 30 60 98 73 15\n", - "192 89 16 10 135 4\n", - "193 104 139 97 29 17\n", - "194 5 29 41 99 69\n", - "195 19 102 135 41 40\n", - "196 58 75 70 82 64\n", - "197 71 97 129 76 13\n", - "198 131 15 77 44 114\n", - "199 79 75 95 128 69\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 均值\n", - "df3 = df2.fillna(value=df2.mean())\n", - "df3.astype(np.int16)" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([ 6, 18, 1, 17, 19, 5, 17, 16, 13, 3])" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "nd = np.random.randint(0,20,size = 10)\n", - "nd" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([ 1, 3, 5, 6, 13, 16, 17, 17, 18, 19])" - ] - }, - "execution_count": 33, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "nd.sort()\n", - "nd" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "14.5" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "(13 + 16)/2" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "14.5" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "np.median(nd)" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          100122.010.05.028.057.0
          10168.0129.016.0114.026.0
          10297.0121.0122.029.065.0
          103141.073.0120.0147.01.0
          104126.082.586.0116.017.0
          10585.082.542.0121.066.0
          106142.065.01.0124.083.0
          107136.0141.086.086.0113.0
          10815.037.0124.0110.0102.0
          10963.030.086.069.058.0
          11068.082.5113.0109.016.0
          1115.051.087.058.0126.0
          11253.097.076.037.045.0
          11342.0148.086.097.065.0
          11470.0138.069.068.0134.0
          11568.0136.0113.022.094.0
          11631.0137.06.020.028.0
          117148.074.0134.04.0124.0
          118102.081.0138.0128.032.0
          11927.0111.013.069.022.0
          12028.093.0121.069.04.0
          121136.082.525.097.019.0
          122111.070.012.038.058.0
          12368.0103.0147.086.08.0
          12410.010.046.063.0149.0
          1257.075.097.0108.031.0
          12688.06.086.069.055.0
          12733.074.0106.050.046.0
          12874.028.026.0100.076.0
          12976.018.0101.069.065.0
          ..................
          170144.0124.077.092.082.0
          17136.098.086.043.080.0
          17251.082.568.034.074.0
          173149.082.518.0141.065.0
          1748.0139.0146.0112.065.0
          175115.082.564.062.09.0
          17668.07.0140.045.0148.0
          17768.043.068.0109.018.0
          17831.0100.086.049.0123.0
          17929.046.069.057.090.0
          180146.086.018.022.046.0
          18171.050.040.069.0140.0
          1824.0100.0147.0116.0110.0
          18355.087.093.069.034.0
          18468.0109.0124.087.082.0
          18510.0118.0139.050.051.0
          18632.012.071.036.065.0
          18794.082.5138.013.0149.0
          18865.0101.0123.0128.086.0
          18943.094.086.029.0132.0
          19068.0135.094.028.0125.0
          19130.060.098.069.015.0
          19289.016.010.0135.04.0
          193104.0139.097.029.017.0
          1945.029.041.099.065.0
          19519.0102.0135.041.040.0
          19658.082.570.082.064.0
          19768.097.0129.076.013.0
          198131.015.086.044.0114.0
          19979.082.595.0128.065.0
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122.0 10.0 5.0 28.0 57.0\n", - "101 68.0 129.0 16.0 114.0 26.0\n", - "102 97.0 121.0 122.0 29.0 65.0\n", - "103 141.0 73.0 120.0 147.0 1.0\n", - "104 126.0 82.5 86.0 116.0 17.0\n", - "105 85.0 82.5 42.0 121.0 66.0\n", - "106 142.0 65.0 1.0 124.0 83.0\n", - "107 136.0 141.0 86.0 86.0 113.0\n", - "108 15.0 37.0 124.0 110.0 102.0\n", - "109 63.0 30.0 86.0 69.0 58.0\n", - "110 68.0 82.5 113.0 109.0 16.0\n", - "111 5.0 51.0 87.0 58.0 126.0\n", - "112 53.0 97.0 76.0 37.0 45.0\n", - "113 42.0 148.0 86.0 97.0 65.0\n", - "114 70.0 138.0 69.0 68.0 134.0\n", - "115 68.0 136.0 113.0 22.0 94.0\n", - "116 31.0 137.0 6.0 20.0 28.0\n", - "117 148.0 74.0 134.0 4.0 124.0\n", - "118 102.0 81.0 138.0 128.0 32.0\n", - "119 27.0 111.0 13.0 69.0 22.0\n", - "120 28.0 93.0 121.0 69.0 4.0\n", - "121 136.0 82.5 25.0 97.0 19.0\n", - "122 111.0 70.0 12.0 38.0 58.0\n", - "123 68.0 103.0 147.0 86.0 8.0\n", - "124 10.0 10.0 46.0 63.0 149.0\n", - "125 7.0 75.0 97.0 108.0 31.0\n", - "126 88.0 6.0 86.0 69.0 55.0\n", - "127 33.0 74.0 106.0 50.0 46.0\n", - "128 74.0 28.0 26.0 100.0 76.0\n", - "129 76.0 18.0 101.0 69.0 65.0\n", - ".. ... ... ... ... ...\n", - "170 144.0 124.0 77.0 92.0 82.0\n", - "171 36.0 98.0 86.0 43.0 80.0\n", - "172 51.0 82.5 68.0 34.0 74.0\n", - "173 149.0 82.5 18.0 141.0 65.0\n", - "174 8.0 139.0 146.0 112.0 65.0\n", - "175 115.0 82.5 64.0 62.0 9.0\n", - "176 68.0 7.0 140.0 45.0 148.0\n", - "177 68.0 43.0 68.0 109.0 18.0\n", - "178 31.0 100.0 86.0 49.0 123.0\n", - "179 29.0 46.0 69.0 57.0 90.0\n", - "180 146.0 86.0 18.0 22.0 46.0\n", - "181 71.0 50.0 40.0 69.0 140.0\n", - "182 4.0 100.0 147.0 116.0 110.0\n", - "183 55.0 87.0 93.0 69.0 34.0\n", - "184 68.0 109.0 124.0 87.0 82.0\n", - "185 10.0 118.0 139.0 50.0 51.0\n", - "186 32.0 12.0 71.0 36.0 65.0\n", - "187 94.0 82.5 138.0 13.0 149.0\n", - "188 65.0 101.0 123.0 128.0 86.0\n", - "189 43.0 94.0 86.0 29.0 132.0\n", - "190 68.0 135.0 94.0 28.0 125.0\n", - "191 30.0 60.0 98.0 69.0 15.0\n", - "192 89.0 16.0 10.0 135.0 4.0\n", - "193 104.0 139.0 97.0 29.0 17.0\n", - "194 5.0 29.0 41.0 99.0 65.0\n", - "195 19.0 102.0 135.0 41.0 40.0\n", - "196 58.0 82.5 70.0 82.0 64.0\n", - "197 68.0 97.0 129.0 76.0 13.0\n", - "198 131.0 15.0 86.0 44.0 114.0\n", - "199 79.0 82.5 95.0 128.0 65.0\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 中位数填充\n", - "df2.median()\n", - "df4 = df2.fillna(df2.median())\n", - "df4" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          100122.010.05.028.057.0
          101NaN129.016.0114.026.0
          10297.0121.0122.029.065.0
          103141.073.0120.0147.01.0
          104126.0NaN86.0116.017.0
          10585.0NaN42.0121.066.0
          106142.065.01.0124.083.0
          107136.0141.0NaN86.0113.0
          10815.037.0124.0110.0102.0
          10963.030.0NaN69.058.0
          110NaNNaN113.0109.016.0
          1115.051.087.058.0126.0
          11253.097.076.037.045.0
          11342.0148.0NaN97.0NaN
          11470.0138.069.068.0134.0
          115NaN136.0113.022.094.0
          11631.0137.06.020.028.0
          117148.074.0134.04.0124.0
          118102.081.0138.0128.032.0
          11927.0111.013.0NaN22.0
          12028.093.0121.0NaN4.0
          121136.0NaN25.097.019.0
          122111.070.012.038.058.0
          123NaN103.0147.086.08.0
          12410.010.046.063.0149.0
          1257.075.097.0108.031.0
          12688.06.0NaNNaN55.0
          12733.074.0106.050.046.0
          12874.028.026.0100.076.0
          12976.018.0101.0NaNNaN
          ..................
          170144.0124.077.092.082.0
          17136.098.0NaN43.080.0
          17251.0NaN68.034.074.0
          173149.0NaN18.0141.0NaN
          1748.0139.0146.0112.0NaN
          175115.0NaN64.062.09.0
          176NaN7.0140.045.0148.0
          177NaN43.068.0109.018.0
          17831.0100.0NaN49.0123.0
          17929.046.069.057.090.0
          180146.086.018.022.046.0
          18171.050.040.0NaN140.0
          1824.0100.0147.0116.0110.0
          18355.087.093.0NaN34.0
          184NaN109.0124.087.082.0
          18510.0118.0139.050.051.0
          18632.012.071.036.0NaN
          18794.0NaN138.013.0149.0
          18865.0101.0123.0128.086.0
          18943.094.0NaN29.0132.0
          19068.0135.094.028.0125.0
          19130.060.098.0NaN15.0
          19289.016.010.0135.04.0
          193104.0139.097.029.017.0
          1945.029.041.099.0NaN
          19519.0102.0135.041.040.0
          19658.0NaN70.082.064.0
          197NaN97.0129.076.013.0
          198131.015.0NaN44.0114.0
          19979.0NaN95.0128.0NaN
          \n", - "

          100 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 122.0 10.0 5.0 28.0 57.0\n", - "101 NaN 129.0 16.0 114.0 26.0\n", - "102 97.0 121.0 122.0 29.0 65.0\n", - "103 141.0 73.0 120.0 147.0 1.0\n", - "104 126.0 NaN 86.0 116.0 17.0\n", - "105 85.0 NaN 42.0 121.0 66.0\n", - "106 142.0 65.0 1.0 124.0 83.0\n", - "107 136.0 141.0 NaN 86.0 113.0\n", - "108 15.0 37.0 124.0 110.0 102.0\n", - "109 63.0 30.0 NaN 69.0 58.0\n", - "110 NaN NaN 113.0 109.0 16.0\n", - "111 5.0 51.0 87.0 58.0 126.0\n", - "112 53.0 97.0 76.0 37.0 45.0\n", - "113 42.0 148.0 NaN 97.0 NaN\n", - "114 70.0 138.0 69.0 68.0 134.0\n", - "115 NaN 136.0 113.0 22.0 94.0\n", - "116 31.0 137.0 6.0 20.0 28.0\n", - "117 148.0 74.0 134.0 4.0 124.0\n", - "118 102.0 81.0 138.0 128.0 32.0\n", - "119 27.0 111.0 13.0 NaN 22.0\n", - "120 28.0 93.0 121.0 NaN 4.0\n", - "121 136.0 NaN 25.0 97.0 19.0\n", - "122 111.0 70.0 12.0 38.0 58.0\n", - "123 NaN 103.0 147.0 86.0 8.0\n", - "124 10.0 10.0 46.0 63.0 149.0\n", - "125 7.0 75.0 97.0 108.0 31.0\n", - "126 88.0 6.0 NaN NaN 55.0\n", - "127 33.0 74.0 106.0 50.0 46.0\n", - "128 74.0 28.0 26.0 100.0 76.0\n", - "129 76.0 18.0 101.0 NaN NaN\n", - ".. ... ... ... ... ...\n", - "170 144.0 124.0 77.0 92.0 82.0\n", - "171 36.0 98.0 NaN 43.0 80.0\n", - "172 51.0 NaN 68.0 34.0 74.0\n", - "173 149.0 NaN 18.0 141.0 NaN\n", - "174 8.0 139.0 146.0 112.0 NaN\n", - "175 115.0 NaN 64.0 62.0 9.0\n", - "176 NaN 7.0 140.0 45.0 148.0\n", - "177 NaN 43.0 68.0 109.0 18.0\n", - "178 31.0 100.0 NaN 49.0 123.0\n", - "179 29.0 46.0 69.0 57.0 90.0\n", - "180 146.0 86.0 18.0 22.0 46.0\n", - "181 71.0 50.0 40.0 NaN 140.0\n", - "182 4.0 100.0 147.0 116.0 110.0\n", - "183 55.0 87.0 93.0 NaN 34.0\n", - "184 NaN 109.0 124.0 87.0 82.0\n", - "185 10.0 118.0 139.0 50.0 51.0\n", - "186 32.0 12.0 71.0 36.0 NaN\n", - "187 94.0 NaN 138.0 13.0 149.0\n", - "188 65.0 101.0 123.0 128.0 86.0\n", - "189 43.0 94.0 NaN 29.0 132.0\n", - "190 68.0 135.0 94.0 28.0 125.0\n", - "191 30.0 60.0 98.0 NaN 15.0\n", - "192 89.0 16.0 10.0 135.0 4.0\n", - "193 104.0 139.0 97.0 29.0 17.0\n", - "194 5.0 29.0 41.0 99.0 NaN\n", - "195 19.0 102.0 135.0 41.0 40.0\n", - "196 58.0 NaN 70.0 82.0 64.0\n", - "197 NaN 97.0 129.0 76.0 13.0\n", - "198 131.0 15.0 NaN 44.0 114.0\n", - "199 79.0 NaN 95.0 128.0 NaN\n", - "\n", - "[100 rows x 5 columns]" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 众数填充,数量最多的那个数\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          100828999101125
          101431109325
          10256103566190
          1034710014713899
          1043846827544
          10518111223126
          106562610614139
          10731377567144
          10835471026063
          109861265788149
          11019140303533
          11176151133
          11231549111969
          1136437502321
          11472571381521
          115551201043225
          11696248922146
          11763086489
          11828461258274
          119853970132111
          12010990447439
          121214810311465
          12211029998057
          123109888113571
          12470103134121121
          12551921172743
          1266929759105
          12765905214822
          12841291711913
          1292410010728139
          ..................
          207012777241631
          2071936192822
          20721166154861
          207347214011234
          2074261081233233
          207546130135124113
          207633181363820
          20771071112954119
          207884551293787
          20799550451984
          2080124746514053
          20812635149145127
          20821921101389
          20838410131714
          208428741056889
          20852393849788
          2086861332612513
          208721124401155
          20882015353137
          208996123123564
          20902243927860
          20911631176058
          20926518131334
          209369491094058
          2094128461082111
          20952659854149
          209611147909266
          209759773140104
          2098102675119
          209997197714348
          \n", - "

          2000 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 82 89 99 101 125\n", - "101 4 31 109 32 5\n", - "102 56 103 56 61 90\n", - "103 47 100 147 138 99\n", - "104 38 46 82 75 44\n", - "105 18 11 122 3 126\n", - "106 56 26 106 14 139\n", - "107 3 137 75 67 144\n", - "108 35 47 102 60 63\n", - "109 86 126 57 88 149\n", - "110 19 140 30 35 33\n", - "111 76 1 5 11 33\n", - "112 31 54 91 119 69\n", - "113 64 37 50 23 21\n", - "114 72 57 138 15 21\n", - "115 55 120 104 32 25\n", - "116 96 24 89 22 146\n", - "117 63 0 8 64 89\n", - "118 28 46 125 82 74\n", - "119 85 39 70 132 111\n", - "120 109 90 44 74 39\n", - "121 2 148 103 114 65\n", - "122 110 29 99 80 57\n", - "123 109 88 81 135 71\n", - "124 70 103 134 121 121\n", - "125 51 92 117 27 43\n", - "126 6 92 97 59 105\n", - "127 65 90 52 148 22\n", - "128 4 129 17 119 13\n", - "129 24 100 107 28 139\n", - "... ... ... ... ... ...\n", - "2070 127 77 24 16 31\n", - "2071 93 61 9 28 22\n", - "2072 116 61 54 8 61\n", - "2073 4 72 140 112 34\n", - "2074 26 108 123 32 33\n", - "2075 46 130 135 124 113\n", - "2076 33 18 136 38 20\n", - "2077 107 11 129 54 119\n", - "2078 84 55 129 37 87\n", - "2079 95 50 45 19 84\n", - "2080 124 74 65 140 53\n", - "2081 26 35 149 145 127\n", - "2082 19 21 101 3 89\n", - "2083 84 10 131 71 4\n", - "2084 28 74 105 68 89\n", - "2085 23 93 84 97 88\n", - "2086 86 133 26 125 13\n", - "2087 21 124 40 115 5\n", - "2088 20 15 35 31 37\n", - "2089 96 123 123 5 64\n", - "2090 22 43 92 78 60\n", - "2091 16 31 17 60 58\n", - "2092 65 18 13 13 34\n", - "2093 69 49 109 40 58\n", - "2094 128 46 10 82 111\n", - "2095 26 59 8 54 149\n", - "2096 111 47 90 92 66\n", - "2097 5 97 73 140 104\n", - "2098 102 6 7 5 119\n", - "2099 97 19 77 143 48\n", - "\n", - "[2000 rows x 5 columns]" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = DataFrame(np.random.randint(0,150,size = (2000,5)),index = np.arange(100,2100),columns=['Python','En','Math','Physic','Chem'])\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(1000):\n", - " # 行索引\n", - " index = np.random.randint(100,2100,size =1)[0]\n", - "\n", - " cols = df.columns\n", - "\n", - " # 列索引\n", - " col = np.random.choice(cols)\n", - "\n", - " df.loc[index,col] = None" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 190\n", - "En 200\n", - "Math 194\n", - "Physic 189\n", - "Chem 181\n", - "dtype: int64" - ] - }, - "execution_count": 44, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.isnull().sum()" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          10082.089.099.0101.0125.0
          1014.031.0109.032.05.0
          10256.0103.056.0NaN90.0
          10347.0100.0147.0138.099.0
          10438.046.0NaN75.044.0
          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 82.0 89.0 99.0 101.0 125.0\n", - "101 4.0 31.0 109.0 32.0 5.0\n", - "102 56.0 103.0 56.0 NaN 90.0\n", - "103 47.0 100.0 147.0 138.0 99.0\n", - "104 38.0 46.0 NaN 75.0 44.0" - ] - }, - "execution_count": 45, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          209526.059.08.054.0149.0
          2096NaN47.090.092.066.0
          20975.097.073.0140.0104.0
          2098102.06.07.05.0119.0
          209997.019.077.0NaN48.0
          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "2095 26.0 59.0 8.0 54.0 149.0\n", - "2096 NaN 47.0 90.0 92.0 66.0\n", - "2097 5.0 97.0 73.0 140.0 104.0\n", - "2098 102.0 6.0 7.0 5.0 119.0\n", - "2099 97.0 19.0 77.0 NaN 48.0" - ] - }, - "execution_count": 46, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.tail()" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([ 82., 4., 56., 47., 38., 18., 3., 35., 86., 19., 76.,\n", - " 31., 64., 72., 55., 96., 63., 28., 85., 109., 2., 110.,\n", - " 70., 51., 6., 65., 24., 48., 44., 11., 114., 129., 87.,\n", - " 108., 125., nan, 140., 132., 91., 34., 54., 30., 12., 98.,\n", - " 142., 79., 13., 77., 40., 139., 39., 81., 112., 36., 22.,\n", - " 5., 120., 17., 127., 119., 59., 146., 89., 103., 8., 97.,\n", - " 130., 73., 83., 122., 95., 100., 41., 21., 136., 80., 101.,\n", - " 50., 27., 71., 16., 141., 126., 102., 145., 15., 52., 94.,\n", - " 10., 33., 137., 9., 128., 88., 26., 84., 93., 1., 7.,\n", - " 131., 107., 148., 0., 105., 66., 32., 115., 118., 58., 53.,\n", - " 29., 42., 57., 62., 25., 60., 69., 133., 68., 20., 106.,\n", - " 147., 78., 90., 124., 149., 92., 75., 117., 143., 99., 37.,\n", - " 123., 45., 61., 121., 135., 138., 116., 14., 104., 74., 46.,\n", - " 111., 23., 43., 49., 144., 113., 67., 134.])" - ] - }, - "execution_count": 48, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 去重之后的数据\n", - "df['Python'].unique()" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "143.0 20\n", - "136.0 20\n", - "102.0 19\n", - "105.0 19\n", - "26.0 19\n", - "69.0 19\n", - "31.0 18\n", - "148.0 18\n", - "75.0 18\n", - "139.0 18\n", - "1.0 18\n", - "35.0 17\n", - "140.0 17\n", - "110.0 17\n", - "125.0 17\n", - "146.0 17\n", - "141.0 17\n", - "64.0 16\n", - "30.0 16\n", - "79.0 16\n", - "73.0 16\n", - "40.0 16\n", - "10.0 15\n", - "6.0 15\n", - "65.0 15\n", - "81.0 15\n", - "28.0 15\n", - "48.0 15\n", - "92.0 15\n", - "103.0 15\n", - " ..\n", - "104.0 9\n", - "12.0 9\n", - "116.0 9\n", - "13.0 9\n", - "59.0 9\n", - "93.0 9\n", - "124.0 9\n", - "85.0 8\n", - "135.0 8\n", - "131.0 8\n", - "68.0 8\n", - "66.0 8\n", - "62.0 8\n", - "120.0 8\n", - "17.0 8\n", - "25.0 8\n", - "145.0 7\n", - "58.0 7\n", - "134.0 7\n", - "113.0 7\n", - "123.0 7\n", - "39.0 7\n", - "34.0 7\n", - "43.0 7\n", - "74.0 6\n", - "144.0 6\n", - "132.0 6\n", - "142.0 5\n", - "67.0 5\n", - "49.0 5\n", - "Name: Python, Length: 150, dtype: int64" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df['Python'].value_counts()" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "8.0 21\n", - "96.0 19\n", - "118.0 19\n", - "24.0 19\n", - "43.0 19\n", - "27.0 19\n", - "19.0 19\n", - "41.0 18\n", - "0.0 18\n", - "3.0 18\n", - "52.0 18\n", - "4.0 17\n", - "137.0 17\n", - "1.0 17\n", - "101.0 17\n", - "51.0 17\n", - "39.0 17\n", - "100.0 17\n", - "127.0 17\n", - "115.0 16\n", - "33.0 16\n", - "112.0 16\n", - "92.0 16\n", - "126.0 16\n", - "133.0 15\n", - "32.0 15\n", - "89.0 15\n", - "95.0 15\n", - "36.0 15\n", - "93.0 15\n", - " ..\n", - "12.0 9\n", - "28.0 9\n", - "106.0 9\n", - "45.0 9\n", - "80.0 9\n", - "84.0 9\n", - "58.0 9\n", - "79.0 9\n", - "71.0 9\n", - "83.0 9\n", - "142.0 9\n", - "7.0 9\n", - "6.0 8\n", - "61.0 8\n", - "149.0 8\n", - "34.0 8\n", - "20.0 8\n", - "38.0 8\n", - "130.0 8\n", - "104.0 7\n", - "120.0 7\n", - "56.0 7\n", - "146.0 7\n", - "98.0 7\n", - "134.0 6\n", - "123.0 6\n", - "35.0 6\n", - "87.0 5\n", - "42.0 5\n", - "119.0 4\n", - "Name: En, Length: 150, dtype: int64" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "en = df['En'].value_counts()\n", - "en" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "8.0" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "en.index[0]" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Python 75.0\n", - "En 74.0\n", - "Math 77.5\n", - "Physic 73.0\n", - "Chem 72.0\n", - "dtype: float64 \n" - ] - } - ], - "source": [ - "s = df.median()\n", - "print(s,type(s))" - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": {}, - "outputs": [], - "source": [ - "zhongshu = []\n", - "for col in df.columns:\n", - " zhongshu.append(df[col].value_counts().index[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 143.0\n", - "En 8.0\n", - "Math 80.0\n", - "Physic 31.0\n", - "Chem 125.0\n", - "dtype: float64" - ] - }, - "execution_count": 57, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s = Series(zhongshu,index = df.columns)\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          10082.089.099.0101.0125.0
          1014.031.0109.032.05.0
          10256.0103.056.031.090.0
          10347.0100.0147.0138.099.0
          10438.046.080.075.044.0
          10518.011.0122.03.0126.0
          10656.026.0106.014.0139.0
          1073.0137.075.067.0144.0
          10835.047.0102.060.063.0
          10986.0126.080.088.0149.0
          11019.0140.080.035.033.0
          11176.08.05.011.033.0
          11231.054.091.0119.069.0
          11364.037.050.023.021.0
          11472.057.0138.015.021.0
          11555.0120.0104.032.025.0
          11696.024.089.031.0146.0
          11763.08.08.064.089.0
          11828.08.0125.082.074.0
          11985.039.070.0132.0111.0
          120109.090.080.074.039.0
          1212.08.0103.0114.065.0
          122110.029.099.080.057.0
          123109.088.081.0135.071.0
          12470.0103.0134.0121.0121.0
          12551.092.0117.031.043.0
          1266.092.097.059.0105.0
          12765.090.052.0148.022.0
          1284.0129.017.0119.013.0
          12924.0100.0107.028.0139.0
          ..................
          2070127.077.024.016.0125.0
          207193.061.09.028.022.0
          2072116.061.054.08.061.0
          20734.072.0140.031.034.0
          2074143.0108.0123.032.033.0
          207546.08.0135.0124.0113.0
          2076143.018.0136.038.0125.0
          2077143.011.0129.054.0119.0
          207884.055.0129.037.087.0
          207995.050.045.019.084.0
          2080124.074.065.031.053.0
          208126.035.0149.0145.0127.0
          208219.021.0101.03.089.0
          208384.08.0131.071.04.0
          208428.074.0105.068.089.0
          208523.093.084.097.088.0
          208686.0133.026.0125.013.0
          208721.0124.040.031.05.0
          208820.015.035.031.037.0
          208996.0123.0123.05.064.0
          209022.043.092.078.060.0
          209116.031.017.060.058.0
          209265.018.013.013.034.0
          209369.049.0109.040.058.0
          2094128.046.010.082.0111.0
          209526.059.08.054.0149.0
          2096143.047.090.092.066.0
          20975.097.073.0140.0104.0
          2098102.06.07.05.0119.0
          209997.019.077.031.048.0
          \n", - "

          2000 rows × 5 columns

          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 82.0 89.0 99.0 101.0 125.0\n", - "101 4.0 31.0 109.0 32.0 5.0\n", - "102 56.0 103.0 56.0 31.0 90.0\n", - "103 47.0 100.0 147.0 138.0 99.0\n", - "104 38.0 46.0 80.0 75.0 44.0\n", - "105 18.0 11.0 122.0 3.0 126.0\n", - "106 56.0 26.0 106.0 14.0 139.0\n", - "107 3.0 137.0 75.0 67.0 144.0\n", - "108 35.0 47.0 102.0 60.0 63.0\n", - "109 86.0 126.0 80.0 88.0 149.0\n", - "110 19.0 140.0 80.0 35.0 33.0\n", - "111 76.0 8.0 5.0 11.0 33.0\n", - "112 31.0 54.0 91.0 119.0 69.0\n", - "113 64.0 37.0 50.0 23.0 21.0\n", - "114 72.0 57.0 138.0 15.0 21.0\n", - "115 55.0 120.0 104.0 32.0 25.0\n", - "116 96.0 24.0 89.0 31.0 146.0\n", - "117 63.0 8.0 8.0 64.0 89.0\n", - "118 28.0 8.0 125.0 82.0 74.0\n", - "119 85.0 39.0 70.0 132.0 111.0\n", - "120 109.0 90.0 80.0 74.0 39.0\n", - "121 2.0 8.0 103.0 114.0 65.0\n", - "122 110.0 29.0 99.0 80.0 57.0\n", - "123 109.0 88.0 81.0 135.0 71.0\n", - "124 70.0 103.0 134.0 121.0 121.0\n", - "125 51.0 92.0 117.0 31.0 43.0\n", - "126 6.0 92.0 97.0 59.0 105.0\n", - "127 65.0 90.0 52.0 148.0 22.0\n", - "128 4.0 129.0 17.0 119.0 13.0\n", - "129 24.0 100.0 107.0 28.0 139.0\n", - "... ... ... ... ... ...\n", - "2070 127.0 77.0 24.0 16.0 125.0\n", - "2071 93.0 61.0 9.0 28.0 22.0\n", - "2072 116.0 61.0 54.0 8.0 61.0\n", - "2073 4.0 72.0 140.0 31.0 34.0\n", - "2074 143.0 108.0 123.0 32.0 33.0\n", - "2075 46.0 8.0 135.0 124.0 113.0\n", - "2076 143.0 18.0 136.0 38.0 125.0\n", - "2077 143.0 11.0 129.0 54.0 119.0\n", - "2078 84.0 55.0 129.0 37.0 87.0\n", - "2079 95.0 50.0 45.0 19.0 84.0\n", - "2080 124.0 74.0 65.0 31.0 53.0\n", - "2081 26.0 35.0 149.0 145.0 127.0\n", - "2082 19.0 21.0 101.0 3.0 89.0\n", - "2083 84.0 8.0 131.0 71.0 4.0\n", - "2084 28.0 74.0 105.0 68.0 89.0\n", - "2085 23.0 93.0 84.0 97.0 88.0\n", - "2086 86.0 133.0 26.0 125.0 13.0\n", - "2087 21.0 124.0 40.0 31.0 5.0\n", - "2088 20.0 15.0 35.0 31.0 37.0\n", - "2089 96.0 123.0 123.0 5.0 64.0\n", - "2090 22.0 43.0 92.0 78.0 60.0\n", - "2091 16.0 31.0 17.0 60.0 58.0\n", - "2092 65.0 18.0 13.0 13.0 34.0\n", - "2093 69.0 49.0 109.0 40.0 58.0\n", - "2094 128.0 46.0 10.0 82.0 111.0\n", - "2095 26.0 59.0 8.0 54.0 149.0\n", - "2096 143.0 47.0 90.0 92.0 66.0\n", - "2097 5.0 97.0 73.0 140.0 104.0\n", - "2098 102.0 6.0 7.0 5.0 119.0\n", - "2099 97.0 19.0 77.0 31.0 48.0\n", - "\n", - "[2000 rows x 5 columns]" - ] - }, - "execution_count": 60, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2 = df.fillna(s)\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 0\n", - "En 0\n", - "Math 0\n", - "Physic 0\n", - "Chem 0\n", - "dtype: int64" - ] - }, - "execution_count": 61, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2.isnull().sum()" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 190\n", - "En 200\n", - "Math 194\n", - "Physic 189\n", - "Chem 181\n", - "dtype: int64" - ] - }, - "execution_count": 62, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.isnull().sum()" - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          10082.089.099.0101.0125.0
          1014.031.0109.032.05.0
          10256.0103.056.0NaN90.0
          10347.0100.0147.0138.099.0
          10438.046.0NaN75.044.0
          10518.011.0122.03.0126.0
          10656.026.0106.014.0139.0
          1073.0137.075.067.0144.0
          10835.047.0102.060.063.0
          10986.0126.0NaN88.0149.0
          11019.0140.0NaN35.033.0
          11176.0NaN5.011.033.0
          11231.054.091.0119.069.0
          11364.037.050.023.021.0
          11472.057.0138.015.021.0
          11555.0120.0104.032.025.0
          11696.024.089.0NaN146.0
          11763.0NaN8.064.089.0
          11828.0NaN125.082.074.0
          11985.039.070.0132.0111.0
          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 82.0 89.0 99.0 101.0 125.0\n", - "101 4.0 31.0 109.0 32.0 5.0\n", - "102 56.0 103.0 56.0 NaN 90.0\n", - "103 47.0 100.0 147.0 138.0 99.0\n", - "104 38.0 46.0 NaN 75.0 44.0\n", - "105 18.0 11.0 122.0 3.0 126.0\n", - "106 56.0 26.0 106.0 14.0 139.0\n", - "107 3.0 137.0 75.0 67.0 144.0\n", - "108 35.0 47.0 102.0 60.0 63.0\n", - "109 86.0 126.0 NaN 88.0 149.0\n", - "110 19.0 140.0 NaN 35.0 33.0\n", - "111 76.0 NaN 5.0 11.0 33.0\n", - "112 31.0 54.0 91.0 119.0 69.0\n", - "113 64.0 37.0 50.0 23.0 21.0\n", - "114 72.0 57.0 138.0 15.0 21.0\n", - "115 55.0 120.0 104.0 32.0 25.0\n", - "116 96.0 24.0 89.0 NaN 146.0\n", - "117 63.0 NaN 8.0 64.0 89.0\n", - "118 28.0 NaN 125.0 82.0 74.0\n", - "119 85.0 39.0 70.0 132.0 111.0" - ] - }, - "execution_count": 65, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df3 = df.iloc[:20]\n", - "df3" - ] - }, - { - "cell_type": "code", - "execution_count": 70, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMathPhysicChem
          10082.089.099.0101.0125.0
          1014.031.0109.032.05.0
          10256.0103.056.090.090.0
          10347.0100.0147.0138.099.0
          10438.046.075.075.044.0
          10518.011.0122.03.0126.0
          10656.026.0106.014.0139.0
          1073.0137.075.067.0144.0
          10835.047.0102.060.063.0
          10986.0126.088.088.0149.0
          11019.0140.035.035.033.0
          11176.05.05.011.033.0
          11231.054.091.0119.069.0
          11364.037.050.023.021.0
          11472.057.0138.015.021.0
          11555.0120.0104.032.025.0
          11696.024.089.0146.0146.0
          11763.08.08.064.089.0
          11828.0125.0125.082.074.0
          11985.039.070.0132.0111.0
          \n", - "
          " - ], - "text/plain": [ - " Python En Math Physic Chem\n", - "100 82.0 89.0 99.0 101.0 125.0\n", - "101 4.0 31.0 109.0 32.0 5.0\n", - "102 56.0 103.0 56.0 90.0 90.0\n", - "103 47.0 100.0 147.0 138.0 99.0\n", - "104 38.0 46.0 75.0 75.0 44.0\n", - "105 18.0 11.0 122.0 3.0 126.0\n", - "106 56.0 26.0 106.0 14.0 139.0\n", - "107 3.0 137.0 75.0 67.0 144.0\n", - "108 35.0 47.0 102.0 60.0 63.0\n", - "109 86.0 126.0 88.0 88.0 149.0\n", - "110 19.0 140.0 35.0 35.0 33.0\n", - "111 76.0 5.0 5.0 11.0 33.0\n", - "112 31.0 54.0 91.0 119.0 69.0\n", - "113 64.0 37.0 50.0 23.0 21.0\n", - "114 72.0 57.0 138.0 15.0 21.0\n", - "115 55.0 120.0 104.0 32.0 25.0\n", - "116 96.0 24.0 89.0 146.0 146.0\n", - "117 63.0 8.0 8.0 64.0 89.0\n", - "118 28.0 125.0 125.0 82.0 74.0\n", - "119 85.0 39.0 70.0 132.0 111.0" - ] - }, - "execution_count": 70, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "'''method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None\n", - " Method to use for filling holes in reindexed Series\n", - " pad / ffill: propagate last valid observation forward to next valid\n", - " backfill / bfill: use NEXT valid observation to fill gap'''\n", - "df3.fillna(method='bfill',axis = 1)" - ] - }, - { - "cell_type": "code", - "execution_count": 71, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2000, 5)" - ] - }, - "execution_count": 71, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "#数据量足够大,空数据比较少,直接删除\n", - "df.shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "df.dro" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/4-pandas多层索引.ipynb b/Day76-90/code/4-pandas多层索引.ipynb deleted file mode 100644 index 01f9dd6..0000000 --- a/Day76-90/code/4-pandas多层索引.ipynb +++ /dev/null @@ -1,568 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "# 数据分析BI-------->人工智能AI\n", - "# 数据分析和数据挖掘一个意思,\n", - "# 工具和软件:Excel 免费版\n", - "# SPSS(一人一年10000)、SAS(一人一年5000)、Matlab 收费\n", - "# R、Python(全方位语言,流行) 免费\n", - "# Python + numpy + scipy + pandas + matplotlib + seaborn + pyEcharts + sklearn + kereas(Tensorflow)+…… \n", - "# 代码,自动化(数据输入----输出结果)\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "a 63\n", - "b 107\n", - "c 16\n", - "d 35\n", - "e 140\n", - "f 83\n", - "dtype: int32" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 多层索引,行列\n", - "# 单层索引\n", - "s = Series(np.random.randint(0,150,size = 6),index=list('abcdef'))\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "张三 期中 114\n", - " 期末 131\n", - "李四 期中 3\n", - " 期末 63\n", - "王五 期中 107\n", - " 期末 34\n", - "dtype: int32" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 多层索引,两层,三层以上(规则一样)\n", - "s2 = Series(np.random.randint(0,150,size = 6),index = pd.MultiIndex.from_product([['张三','李四','王五'],['期中','期末']]))\n", - "s2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          张三期中73525
          期末373656
          李四期中14981142
          期末711380
          王五期中1194103
          期末2512183
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "张三 期中 73 5 25\n", - " 期末 37 36 56\n", - "李四 期中 149 81 142\n", - " 期末 71 138 0\n", - "王五 期中 11 94 103\n", - " 期末 25 121 83" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = DataFrame(np.random.randint(0,150,size = (6,3)),columns=['Python','En','Math'],index =pd.MultiIndex.from_product([['张三','李四','王五'],['期中','期末']]) )\n", - "\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          张三期中A153117
          B8256123
          期末A14278
          B695017
          李四期中A9187143
          B12011839
          期末A567655
          B11105121
          王五期中A147781
          B128126146
          期末A4945114
          B1212677
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "张三 期中 A 15 31 17\n", - " B 82 56 123\n", - " 期末 A 14 2 78\n", - " B 69 50 17\n", - "李四 期中 A 91 87 143\n", - " B 120 118 39\n", - " 期末 A 56 76 55\n", - " B 11 105 121\n", - "王五 期中 A 147 78 1\n", - " B 128 126 146\n", - " 期末 A 49 45 114\n", - " B 121 26 77" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 三层索引\n", - "df3 = DataFrame(np.random.randint(0,150,size = (12,3)),columns=['Python','En','Math'],index =pd.MultiIndex.from_product([['张三','李四','王五'],['期中','期末'],['A','B']]) )\n", - "\n", - "df3" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "73" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 先获取列后获取行\n", - "df['Python']['张三']['期中']" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "df2 = df.copy()" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          张三期中73525
          期末373656
          李四期中14981142
          期末711380
          王五期中1194103
          期末2512183
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "张三 期中 73 5 25\n", - " 期末 37 36 56\n", - "李四 期中 149 81 142\n", - " 期末 71 138 0\n", - "王五 期中 11 94 103\n", - " 期末 25 121 83" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2.sort_index()" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "73" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 先获取行,后获取列\n", - "df.loc['张三'].loc['期中']['Python']" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          张三期中73525
          期末373656
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "张三 期中 73 5 25\n", - " 期末 37 36 56" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.iloc[[0,1]]" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/5-pandas多层索引计算.ipynb b/Day76-90/code/5-pandas多层索引计算.ipynb deleted file mode 100644 index 22e1c8e..0000000 --- a/Day76-90/code/5-pandas多层索引计算.ipynb +++ /dev/null @@ -1,1000 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          期中期末期中期末期中期末
          A1311011731517
          B6234531012457
          C247636117123105
          D11246794246122
          E661131044510108
          F11110844113221
          \n", - "
          " - ], - "text/plain": [ - " Python En Math \n", - " 期中 期末 期中 期末 期中 期末\n", - "A 131 101 1 73 15 17\n", - "B 62 34 53 101 24 57\n", - "C 24 76 36 117 123 105\n", - "D 112 46 79 42 46 122\n", - "E 66 113 104 45 10 108\n", - "F 111 108 4 41 132 21" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 多层列索引\n", - "df = DataFrame(np.random.randint(0,150,size = (6,6)),index = list('ABCDEF'),\n", - " columns=pd.MultiIndex.from_product([['Python','En','Math'],['期中','期末']]))\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 期中 84.3\n", - " 期末 79.7\n", - "En 期中 46.2\n", - " 期末 69.8\n", - "Math 期中 58.3\n", - " 期末 71.7\n", - "dtype: float64" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# round保留2位小数\n", - "df.mean().round(1)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          期中期末期中期末期中期末
          A1311011731517
          B6234531012457
          C247636117123105
          D11246794246122
          E661131044510108
          F11110844113221
          \n", - "
          " - ], - "text/plain": [ - " Python En Math \n", - " 期中 期末 期中 期末 期中 期末\n", - "A 131 101 1 73 15 17\n", - "B 62 34 53 101 24 57\n", - "C 24 76 36 117 123 105\n", - "D 112 46 79 42 46 122\n", - "E 66 113 104 45 10 108\n", - "F 111 108 4 41 132 21" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          A116.037.016.0
          B48.077.040.5
          C50.076.5114.0
          D79.060.584.0
          E89.574.559.0
          F109.522.576.5
          \n", - "
          " - ], - "text/plain": [ - " Python En Math\n", - "A 116.0 37.0 16.0\n", - "B 48.0 77.0 40.5\n", - "C 50.0 76.5 114.0\n", - "D 79.0 60.5 84.0\n", - "E 89.5 74.5 59.0\n", - "F 109.5 22.5 76.5" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# axis = 0代表行\n", - "# axis = 1代表列\n", - "df.mean(axis = 1,level = 0)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          期中期末
          A49.063.7
          B46.364.0
          C61.099.3
          D79.070.0
          E60.088.7
          F82.356.7
          \n", - "
          " - ], - "text/plain": [ - " 期中 期末\n", - "A 49.0 63.7\n", - "B 46.3 64.0\n", - "C 61.0 99.3\n", - "D 79.0 70.0\n", - "E 60.0 88.7\n", - "F 82.3 56.7" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.mean(axis = 1,level = 1).round(1)" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonEnMath
          期中期末期中期末期中期末
          A1311011731517
          B6234531012457
          C247636117123105
          D11246794246122
          E661131044510108
          F11110844113221
          \n", - "
          " - ], - "text/plain": [ - " Python En Math \n", - " 期中 期末 期中 期末 期中 期末\n", - "A 131 101 1 73 15 17\n", - "B 62 34 53 101 24 57\n", - "C 24 76 36 117 123 105\n", - "D 112 46 79 42 46 122\n", - "E 66 113 104 45 10 108\n", - "F 111 108 4 41 132 21" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          EnMathPython
          A期中115131
          期末7317101
          B期中532462
          期末1015734
          C期中3612324
          期末11710576
          D期中7946112
          期末4212246
          E期中1041066
          期末45108113
          F期中4132111
          期末4121108
          \n", - "
          " - ], - "text/plain": [ - " En Math Python\n", - "A 期中 1 15 131\n", - " 期末 73 17 101\n", - "B 期中 53 24 62\n", - " 期末 101 57 34\n", - "C 期中 36 123 24\n", - " 期末 117 105 76\n", - "D 期中 79 46 112\n", - " 期末 42 122 46\n", - "E 期中 104 10 66\n", - " 期末 45 108 113\n", - "F 期中 4 132 111\n", - " 期末 41 21 108" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 行和列的多层索引,进行转换\n", - "# Stack the prescribed level(s) from columns to index.\n", - "# 从列变成行\n", - "df2 = df.stack(level = 1)\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          EnMathPython
          ABCDEFABCDEFABCDEF
          期中1533679104415241234610132131622411266111
          期末73101117424541175710512210821101347646113108
          \n", - "
          " - ], - "text/plain": [ - " En Math Python \n", - " A B C D E F A B C D E F A B C D E F\n", - "期中 1 53 36 79 104 4 15 24 123 46 10 132 131 62 24 112 66 111\n", - "期末 73 101 117 42 45 41 17 57 105 122 108 21 101 34 76 46 113 108" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 从行变成列\n", - "df2.unstack(level= 0 )" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          EnMathPython
          期中期末期中期末期中期末
          A1731517131101
          B5310124576234
          C361171231052476
          D79424612211246
          E104451010866113
          F44113221111108
          \n", - "
          " - ], - "text/plain": [ - " En Math Python \n", - " 期中 期末 期中 期末 期中 期末\n", - "A 1 73 15 17 131 101\n", - "B 53 101 24 57 62 34\n", - "C 36 117 123 105 24 76\n", - "D 79 42 46 122 112 46\n", - "E 104 45 10 108 66 113\n", - "F 4 41 132 21 111 108" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2.unstack(level = 1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/6-pandas数据集成.ipynb b/Day76-90/code/6-pandas数据集成.ipynb deleted file mode 100644 index e128ee4..0000000 --- a/Day76-90/code/6-pandas数据集成.ipynb +++ /dev/null @@ -1,1209 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# 数据分析数据挖掘\n", - "# 有数据情况下:\n", - "# 数据预处理\n", - "# 数据清洗(空数据,异常值)\n", - "# 数据集成(多个数据合并到一起,级联)数据可能存放在多个表中\n", - "# 数据转化\n", - "# 数据规约(属性减少(不重要的属性删除),数据减少去重操作)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 5, 12, 67, 29, 46, 103, 53, 53, 139, 87],\n", - " [126, 33, 55, 104, 45, 70, 96, 133, 116, 43],\n", - " [ 84, 45, 17, 42, 19, 11, 125, 43, 54, 39],\n", - " [ 97, 68, 99, 90, 28, 60, 135, 84, 111, 63],\n", - " [114, 56, 30, 81, 48, 73, 119, 65, 20, 22]])" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "array([[115, 128, 122, 127, 4, 135, 26, 25, 131, 139],\n", - " [ 66, 119, 37, 136, 101, 40, 102, 127, 148, 127],\n", - " [ 89, 80, 140, 133, 51, 142, 47, 27, 54, 23],\n", - " [ 64, 127, 33, 128, 60, 106, 67, 94, 110, 76],\n", - " [ 6, 21, 23, 96, 10, 62, 26, 79, 149, 43],\n", - " [116, 143, 132, 118, 68, 21, 57, 133, 124, 124]])" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# 首先看numpy数组的集成\n", - "nd1 = np.random.randint(0,150,size = (5,10))\n", - "\n", - "nd2 = np.random.randint(0,150,size = (6,10))\n", - "display(nd1,nd2)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[ 5, 12, 67, 29, 46, 103, 53, 53, 139, 87],\n", - " [126, 33, 55, 104, 45, 70, 96, 133, 116, 43],\n", - " [ 84, 45, 17, 42, 19, 11, 125, 43, 54, 39],\n", - " [ 97, 68, 99, 90, 28, 60, 135, 84, 111, 63],\n", - " [114, 56, 30, 81, 48, 73, 119, 65, 20, 22],\n", - " [115, 128, 122, 127, 4, 135, 26, 25, 131, 139],\n", - " [ 66, 119, 37, 136, 101, 40, 102, 127, 148, 127],\n", - " [ 89, 80, 140, 133, 51, 142, 47, 27, 54, 23],\n", - " [ 64, 127, 33, 128, 60, 106, 67, 94, 110, 76],\n", - " [ 6, 21, 23, 96, 10, 62, 26, 79, 149, 43],\n", - " [116, 143, 132, 118, 68, 21, 57, 133, 124, 124]])" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 原来数据一个5行,一个是6行,级联之后变成了11行\n", - "nd3 = np.concatenate([nd1,nd2],axis = 0)\n", - "nd3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[110, 38, 144, 92, 38, 2, 67, 2, 103, 81],\n", - " [ 56, 61, 61, 22, 108, 145, 95, 44, 40, 100],\n", - " [ 65, 74, 85, 123, 47, 117, 35, 55, 120, 20],\n", - " [ 15, 9, 4, 84, 71, 133, 140, 13, 71, 91],\n", - " [ 94, 31, 41, 5, 7, 32, 50, 24, 18, 120]])" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "array([[ 65, 149, 86, 138, 98],\n", - " [136, 49, 102, 45, 140],\n", - " [ 13, 124, 94, 81, 73],\n", - " [ 82, 38, 0, 75, 94],\n", - " [146, 28, 143, 61, 49]])" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "nd1 = np.random.randint(0,150,size = (5,10))\n", - "\n", - "nd2 = np.random.randint(0,150,size = (5,5))\n", - "display(nd1,nd2)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array([[110, 38, 144, 92, 38, 2, 67, 2, 103, 81, 65, 149, 86,\n", - " 138, 98],\n", - " [ 56, 61, 61, 22, 108, 145, 95, 44, 40, 100, 136, 49, 102,\n", - " 45, 140],\n", - " [ 65, 74, 85, 123, 47, 117, 35, 55, 120, 20, 13, 124, 94,\n", - " 81, 73],\n", - " [ 15, 9, 4, 84, 71, 133, 140, 13, 71, 91, 82, 38, 0,\n", - " 75, 94],\n", - " [ 94, 31, 41, 5, 7, 32, 50, 24, 18, 120, 146, 28, 143,\n", - " 61, 49]])" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# axis = 0行级联(第一维度的级联),axis = 1(第二个维度的级联,列的级联)\n", - "np.concatenate((nd1,nd2),axis = 1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# pandas级联操作,pandas基于numpy\n", - "# pandas的级联类似" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A1135380
          B1354052
          C1441864
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 113 53 80\n", - "B 135 40 52\n", - "C 144 18 64" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          D126118146
          E1478127
          F87631
          G359533
          H13011791
          I12498122
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "D 126 118 146\n", - "E 147 81 27\n", - "F 87 63 1\n", - "G 35 95 33\n", - "H 130 117 91\n", - "I 124 98 122" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "df1 = DataFrame(np.random.randint(0,150,size = (3,3)),index = list('ABC'),columns=['Python','Math','En'])\n", - "\n", - "df2 = DataFrame(np.random.randint(0,150,size = (6,3)),index = list('DEFGHI'),columns=['Python','Math','En'])\n", - "\n", - "display(df1,df2)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A1135380
          B1354052
          C1441864
          D126118146
          E1478127
          F87631
          G359533
          H13011791
          I12498122
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 113 53 80\n", - "B 135 40 52\n", - "C 144 18 64\n", - "D 126 118 146\n", - "E 147 81 27\n", - "F 87 63 1\n", - "G 35 95 33\n", - "H 130 117 91\n", - "I 124 98 122" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pandas汇总数据,数据集成\n", - "df1.append(df2)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A1135380
          B1354052
          C1441864
          D126118146
          E1478127
          F87631
          G359533
          H13011791
          I12498122
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 113 53 80\n", - "B 135 40 52\n", - "C 144 18 64\n", - "D 126 118 146\n", - "E 147 81 27\n", - "F 87 63 1\n", - "G 35 95 33\n", - "H 130 117 91\n", - "I 124 98 122" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pd.concat([df1,df2])" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version\n", - "of pandas will change to not sort by default.\n", - "\n", - "To accept the future behavior, pass 'sort=False'.\n", - "\n", - "To retain the current behavior and silence the warning, pass 'sort=True'.\n", - "\n", - " \"\"\"Entry point for launching an IPython kernel.\n" - ] - }, - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEnPythonMathEn
          A113.053.080.0NaNNaNNaN
          B135.040.052.0NaNNaNNaN
          C144.018.064.0NaNNaNNaN
          DNaNNaNNaN126.0118.0146.0
          ENaNNaNNaN147.081.027.0
          FNaNNaNNaN87.063.01.0
          GNaNNaNNaN35.095.033.0
          HNaNNaNNaN130.0117.091.0
          INaNNaNNaN124.098.0122.0
          \n", - "
          " - ], - "text/plain": [ - " Python Math En Python Math En\n", - "A 113.0 53.0 80.0 NaN NaN NaN\n", - "B 135.0 40.0 52.0 NaN NaN NaN\n", - "C 144.0 18.0 64.0 NaN NaN NaN\n", - "D NaN NaN NaN 126.0 118.0 146.0\n", - "E NaN NaN NaN 147.0 81.0 27.0\n", - "F NaN NaN NaN 87.0 63.0 1.0\n", - "G NaN NaN NaN 35.0 95.0 33.0\n", - "H NaN NaN NaN 130.0 117.0 91.0\n", - "I NaN NaN NaN 124.0 98.0 122.0" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pd.concat([df1,df2],axis = 1,ignore_index = False)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A225813
          B995735
          C512824
          E560111
          F13723121
          G4978115
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 22 58 13\n", - "B 99 57 35\n", - "C 51 28 24\n", - "E 5 60 111\n", - "F 137 23 121\n", - "G 49 78 115" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A11811381
          B5122126
          C0115128
          E10013094
          F4993140
          G705994
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 118 113 81\n", - "B 51 22 126\n", - "C 0 115 128\n", - "E 100 130 94\n", - "F 49 93 140\n", - "G 70 59 94" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# 期中\n", - "df1 = DataFrame(np.random.randint(0,150,size = (6,3)),index = list('ABCEFG'),columns=['Python','Math','En'])\n", - "\n", - "# 期末\n", - "df2 = DataFrame(np.random.randint(0,150,size = (6,3)),index = list('ABCEFG'),columns=['Python','Math','En'])\n", - "\n", - "display(df1,df2)" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          期中A225813
          B995735
          C512824
          E560111
          F13723121
          G4978115
          期末A11811381
          B5122126
          C0115128
          E10013094
          F4993140
          G705994
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "期中 A 22 58 13\n", - " B 99 57 35\n", - " C 51 28 24\n", - " E 5 60 111\n", - " F 137 23 121\n", - " G 49 78 115\n", - "期末 A 118 113 81\n", - " B 51 22 126\n", - " C 0 115 128\n", - " E 100 130 94\n", - " F 49 93 140\n", - " G 70 59 94" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df3 = pd.concat([df1,df2],axis = 0,keys = ['期中','期末'])\n", - "df3" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A期中225813
          期末11811381
          B期中995735
          期末5122126
          C期中512824
          期末0115128
          E期中560111
          期末10013094
          F期中13723121
          期末4993140
          G期中4978115
          期末705994
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 期中 22 58 13\n", - " 期末 118 113 81\n", - "B 期中 99 57 35\n", - " 期末 51 22 126\n", - "C 期中 51 28 24\n", - " 期末 0 115 128\n", - "E 期中 5 60 111\n", - " 期末 100 130 94\n", - "F 期中 137 23 121\n", - " 期末 49 93 140\n", - "G 期中 49 78 115\n", - " 期末 70 59 94" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df3.unstack(level = 0).stack()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/7-pandas数据集成merge.ipynb b/Day76-90/code/7-pandas数据集成merge.ipynb deleted file mode 100644 index 8b2eefc..0000000 --- a/Day76-90/code/7-pandas数据集成merge.ipynb +++ /dev/null @@ -1,1272 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# 上一讲,append,concat数据集成方法\n", - "# merge融合,根据某一共同属性进行级联,高级用法" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          namesexid
          0A1
          1B2
          2C3
          3D4
          4E5
          5F6
          \n", - "
          " - ], - "text/plain": [ - " name sex id\n", - "0 A 男 1\n", - "1 B 女 2\n", - "2 C 女 3\n", - "3 D 女 4\n", - "4 E 男 5\n", - "5 F 男 6" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df1 = DataFrame({'name':['A','B','C','D','E','F'],\n", - " 'sex':['男','女','女','女','男','男'],\n", - " 'id':[1,2,3,4,5,6]})\n", - "df1" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          agesalaryid
          022120001
          125150002
          227200003
          321300004
          418100005
          52980007
          \n", - "
          " - ], - "text/plain": [ - " age salary id\n", - "0 22 12000 1\n", - "1 25 15000 2\n", - "2 27 20000 3\n", - "3 21 30000 4\n", - "4 18 10000 5\n", - "5 29 8000 7" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2 = DataFrame({'age':[22,25,27,21,18,29],'salary':[12000,15000,20000,30000,10000,8000],'id':[1,2,3,4,5,7]})\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\python36\\lib\\site-packages\\pandas\\core\\frame.py:6692: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version\n", - "of pandas will change to not sort by default.\n", - "\n", - "To accept the future behavior, pass 'sort=False'.\n", - "\n", - "To retain the current behavior and silence the warning, pass 'sort=True'.\n", - "\n", - " sort=sort)\n" - ] - }, - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          ageidnamesalarysex
          0NaN1ANaN
          1NaN2BNaN
          2NaN3CNaN
          3NaN4DNaN
          4NaN5ENaN
          5NaN6FNaN
          022.01NaN12000.0NaN
          125.02NaN15000.0NaN
          227.03NaN20000.0NaN
          321.04NaN30000.0NaN
          418.05NaN10000.0NaN
          529.07NaN8000.0NaN
          \n", - "
          " - ], - "text/plain": [ - " age id name salary sex\n", - "0 NaN 1 A NaN 男\n", - "1 NaN 2 B NaN 女\n", - "2 NaN 3 C NaN 女\n", - "3 NaN 4 D NaN 女\n", - "4 NaN 5 E NaN 男\n", - "5 NaN 6 F NaN 男\n", - "0 22.0 1 NaN 12000.0 NaN\n", - "1 25.0 2 NaN 15000.0 NaN\n", - "2 27.0 3 NaN 20000.0 NaN\n", - "3 21.0 4 NaN 30000.0 NaN\n", - "4 18.0 5 NaN 10000.0 NaN\n", - "5 29.0 7 NaN 8000.0 NaN" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df1.append(df2)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          namesexidagesalaryid
          0A122120001
          1B225150002
          2C327200003
          3D421300004
          4E518100005
          5F62980007
          \n", - "
          " - ], - "text/plain": [ - " name sex id age salary id\n", - "0 A 男 1 22 12000 1\n", - "1 B 女 2 25 15000 2\n", - "2 C 女 3 27 20000 3\n", - "3 D 女 4 21 30000 4\n", - "4 E 男 5 18 10000 5\n", - "5 F 男 6 29 8000 7" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pd.concat([df1,df2],axis = 1)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          namesexidagesalary
          0A12212000
          1B22515000
          2C32720000
          3D42130000
          4E51810000
          \n", - "
          " - ], - "text/plain": [ - " name sex id age salary\n", - "0 A 男 1 22 12000\n", - "1 B 女 2 25 15000\n", - "2 C 女 3 27 20000\n", - "3 D 女 4 21 30000\n", - "4 E 男 5 18 10000" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df1.merge(df2)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          namesexidagesalary
          0A122.012000.0
          1B225.015000.0
          2C327.020000.0
          3D421.030000.0
          4E518.010000.0
          5F6NaNNaN
          6NaNNaN729.08000.0
          \n", - "
          " - ], - "text/plain": [ - " name sex id age salary\n", - "0 A 男 1 22.0 12000.0\n", - "1 B 女 2 25.0 15000.0\n", - "2 C 女 3 27.0 20000.0\n", - "3 D 女 4 21.0 30000.0\n", - "4 E 男 5 18.0 10000.0\n", - "5 F 男 6 NaN NaN\n", - "6 NaN NaN 7 29.0 8000.0" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df1.merge(df2,how = 'outer')" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A401590
          B595283
          C14138137
          D897853
          E811013
          F757986
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 40 15 90\n", - "B 59 52 83\n", - "C 14 138 137\n", - "D 89 78 53\n", - "E 81 101 3\n", - "F 75 79 86" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df = DataFrame(np.random.randint(0,150,size = (6,3)),index = list('ABCDEF'),columns=['Python','Math','En'])\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Python 59.7\n", - "Math 77.2\n", - "En 75.3\n", - "dtype: float64" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "s = df.mean().round(1)\n", - "s" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          score_mean
          Python59.7
          Math77.2
          En75.3
          \n", - "
          " - ], - "text/plain": [ - " score_mean\n", - "Python 59.7\n", - "Math 77.2\n", - "En 75.3" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2 = DataFrame(s)\n", - "df2.columns = ['score_mean']\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          score_mean59.777.275.3
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "score_mean 59.7 77.2 75.3" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df3 = df2.T\n", - "df3" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEn
          A40.015.090.0
          B59.052.083.0
          C14.0138.0137.0
          D89.078.053.0
          E81.0101.03.0
          F75.079.086.0
          score_mean59.777.275.3
          \n", - "
          " - ], - "text/plain": [ - " Python Math En\n", - "A 40.0 15.0 90.0\n", - "B 59.0 52.0 83.0\n", - "C 14.0 138.0 137.0\n", - "D 89.0 78.0 53.0\n", - "E 81.0 101.0 3.0\n", - "F 75.0 79.0 86.0\n", - "score_mean 59.7 77.2 75.3" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df4 = df.append(df3)\n", - "df4" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          score_mean
          A48.3
          B64.7
          C96.3
          D73.3
          E61.7
          F80.0
          score_mean70.7
          \n", - "
          " - ], - "text/plain": [ - " score_mean\n", - "A 48.3\n", - "B 64.7\n", - "C 96.3\n", - "D 73.3\n", - "E 61.7\n", - "F 80.0\n", - "score_mean 70.7" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df5 = DataFrame(df4.mean(axis = 1).round(1))\n", - "df5.columns = ['score_mean']\n", - "df5" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          PythonMathEnscore_mean
          A40.015.090.048.3
          B59.052.083.064.7
          C14.0138.0137.096.3
          D89.078.053.073.3
          E81.0101.03.061.7
          F75.079.086.080.0
          score_mean59.777.275.370.7
          \n", - "
          " - ], - "text/plain": [ - " Python Math En score_mean\n", - "A 40.0 15.0 90.0 48.3\n", - "B 59.0 52.0 83.0 64.7\n", - "C 14.0 138.0 137.0 96.3\n", - "D 89.0 78.0 53.0 73.3\n", - "E 81.0 101.0 3.0 61.7\n", - "F 75.0 79.0 86.0 80.0\n", - "score_mean 59.7 77.2 75.3 70.7" - ] - }, - "execution_count": 40, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df4.merge(df5,left_index=True,right_index=True)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/8-pandas分组聚合操作.ipynb b/Day76-90/code/8-pandas分组聚合操作.ipynb deleted file mode 100644 index 7c16aff..0000000 --- a/Day76-90/code/8-pandas分组聚合操作.ipynb +++ /dev/null @@ -1,877 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "# 分组聚合透视\n", - "# 很多时候属性是相似的\n", - "\n", - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          HandSmokesexweightIQ
          0rightyesmale80100
          1leftyesfemale50120
          2leftnofemale4890
          3rightnomale75130
          4rightyesmale68140
          5rightnomale10080
          6rightnofemale4094
          7rightnofemale90110
          8leftnomale88100
          9rightyesfemale76160
          \n", - "
          " - ], - "text/plain": [ - " Hand Smoke sex weight IQ\n", - "0 right yes male 80 100\n", - "1 left yes female 50 120\n", - "2 left no female 48 90\n", - "3 right no male 75 130\n", - "4 right yes male 68 140\n", - "5 right no male 100 80\n", - "6 right no female 40 94\n", - "7 right no female 90 110\n", - "8 left no male 88 100\n", - "9 right yes female 76 160" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 走右手习惯,是否抽烟,性别,对体重,智商,有一定影响\n", - "\n", - "df = DataFrame({'Hand':['right','left','left','right','right','right','right','right','left','right'],\n", - " 'Smoke':['yes','yes','no','no','yes','no','no','no','no','yes'],\n", - " 'sex':['male','female','female','male','male','male','female','female','male','female'],\n", - " 'weight':[80,50,48,75,68,100,40,90,88,76],\n", - " 'IQ':[100,120,90,130,140,80,94,110,100,160]})\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# 分组聚合查看规律,某一条件下规律" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          weightIQ
          Hand
          left62.0103.3
          right75.6116.3
          \n", - "
          " - ], - "text/plain": [ - " weight IQ\n", - "Hand \n", - "left 62.0 103.3\n", - "right 75.6 116.3" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "data = df.groupby(by = ['Hand'])[['weight','IQ']].mean().round(1)\n", - "data" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          weight
          Hand
          left62.0
          right75.6
          \n", - "
          " - ], - "text/plain": [ - " weight\n", - "Hand \n", - "left 62.0\n", - "right 75.6" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.groupby(by = ['Hand'])[['weight']].apply(np.mean).round(1)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "df2 = df.groupby(by = ['Hand'])[['weight']].transform(np.mean).round(1)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          weight_mean
          075.6
          162.0
          262.0
          375.6
          475.6
          575.6
          675.6
          775.6
          862.0
          975.6
          \n", - "
          " - ], - "text/plain": [ - " weight_mean\n", - "0 75.6\n", - "1 62.0\n", - "2 62.0\n", - "3 75.6\n", - "4 75.6\n", - "5 75.6\n", - "6 75.6\n", - "7 75.6\n", - "8 62.0\n", - "9 75.6" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df2 = df2.add_suffix('_mean')\n", - "df2" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          HandSmokesexweightIQweight_mean
          0rightyesmale8010075.6
          1leftyesfemale5012062.0
          2leftnofemale489062.0
          3rightnomale7513075.6
          4rightyesmale6814075.6
          5rightnomale1008075.6
          6rightnofemale409475.6
          7rightnofemale9011075.6
          8leftnomale8810062.0
          9rightyesfemale7616075.6
          \n", - "
          " - ], - "text/plain": [ - " Hand Smoke sex weight IQ weight_mean\n", - "0 right yes male 80 100 75.6\n", - "1 left yes female 50 120 62.0\n", - "2 left no female 48 90 62.0\n", - "3 right no male 75 130 75.6\n", - "4 right yes male 68 140 75.6\n", - "5 right no male 100 80 75.6\n", - "6 right no female 40 94 75.6\n", - "7 right no female 90 110 75.6\n", - "8 left no male 88 100 62.0\n", - "9 right yes female 76 160 75.6" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df3 = df.merge(df2,left_index=True,right_index=True)\n", - "df3" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "Hand\n", - "left ([3, 3], [62.0, 103.3])\n", - "right ([7, 7], [75.6, 116.3])\n", - "dtype: object" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "def count(x):\n", - " \n", - " return (x.count(),x.mean().round(1))\n", - "\n", - "df.groupby(by = ['Hand'])[['weight','IQ']].apply(count)" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          IQ
          Handsex
          leftfemale120
          male100
          rightfemale160
          male140
          \n", - "
          " - ], - "text/plain": [ - " IQ\n", - "Hand sex \n", - "left female 120\n", - " male 100\n", - "right female 160\n", - " male 140" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "df.groupby(by = ['Hand','sex'])[['IQ']].max()" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "data = df.groupby(by = ['Hand'])['IQ','weight']\n", - "data" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          IQweight
          maxmeanmaxmean
          Hand
          left120103.38862.0
          right160116.310075.6
          \n", - "
          " - ], - "text/plain": [ - " IQ weight \n", - " max mean max mean\n", - "Hand \n", - "left 120 103.3 88 62.0\n", - "right 160 116.3 100 75.6" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "data.agg(['max','mean']).round(1)" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          IQweight
          Hand
          left12062.0
          right16075.6
          \n", - "
          " - ], - "text/plain": [ - " IQ weight\n", - "Hand \n", - "left 120 62.0\n", - "right 160 75.6" - ] - }, - "execution_count": 35, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "data.agg({'IQ':'max','weight':'mean'}).round(1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/9-pandas数据集成实战.ipynb b/Day76-90/code/9-pandas数据集成实战.ipynb deleted file mode 100644 index 063a939..0000000 --- a/Day76-90/code/9-pandas数据集成实战.ipynb +++ /dev/null @@ -1,6213 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "import pandas as pd\n", - "\n", - "from pandas import Series,DataFrame" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# csv类型文件呢,文本文件,excel打开,格式化的文件,所以excel可以直接读取成表格\n", - "# 美国人口的一些情况\n", - "# pandas分析一下美国人口数据" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          statearea (sq. mi)
          0Alabama52423
          1Alaska656425
          2Arizona114006
          3Arkansas53182
          4California163707
          5Colorado104100
          6Connecticut5544
          7Delaware1954
          8Florida65758
          9Georgia59441
          10Hawaii10932
          11Idaho83574
          12Illinois57918
          13Indiana36420
          14Iowa56276
          15Kansas82282
          16Kentucky40411
          17Louisiana51843
          18Maine35387
          19Maryland12407
          20Massachusetts10555
          21Michigan96810
          22Minnesota86943
          23Mississippi48434
          24Missouri69709
          25Montana147046
          26Nebraska77358
          27Nevada110567
          28New Hampshire9351
          29New Jersey8722
          30New Mexico121593
          31New York54475
          32North Carolina53821
          33North Dakota70704
          34Ohio44828
          35Oklahoma69903
          36Oregon98386
          37Pennsylvania46058
          38Rhode Island1545
          39South Carolina32007
          40South Dakota77121
          41Tennessee42146
          42Texas268601
          43Utah84904
          44Vermont9615
          45Virginia42769
          46Washington71303
          47West Virginia24231
          48Wisconsin65503
          49Wyoming97818
          50District of Columbia68
          51Puerto Rico3515
          \n", - "
          " - ], - "text/plain": [ - " state area (sq. mi)\n", - "0 Alabama 52423\n", - "1 Alaska 656425\n", - "2 Arizona 114006\n", - "3 Arkansas 53182\n", - "4 California 163707\n", - "5 Colorado 104100\n", - "6 Connecticut 5544\n", - "7 Delaware 1954\n", - "8 Florida 65758\n", - "9 Georgia 59441\n", - "10 Hawaii 10932\n", - "11 Idaho 83574\n", - "12 Illinois 57918\n", - "13 Indiana 36420\n", - "14 Iowa 56276\n", - "15 Kansas 82282\n", - "16 Kentucky 40411\n", - "17 Louisiana 51843\n", - "18 Maine 35387\n", - "19 Maryland 12407\n", - "20 Massachusetts 10555\n", - "21 Michigan 96810\n", - "22 Minnesota 86943\n", - "23 Mississippi 48434\n", - "24 Missouri 69709\n", - "25 Montana 147046\n", - "26 Nebraska 77358\n", - "27 Nevada 110567\n", - "28 New Hampshire 9351\n", - "29 New Jersey 8722\n", - "30 New Mexico 121593\n", - "31 New York 54475\n", - "32 North Carolina 53821\n", - "33 North Dakota 70704\n", - "34 Ohio 44828\n", - "35 Oklahoma 69903\n", - "36 Oregon 98386\n", - "37 Pennsylvania 46058\n", - "38 Rhode Island 1545\n", - "39 South Carolina 32007\n", - "40 South Dakota 77121\n", - "41 Tennessee 42146\n", - "42 Texas 268601\n", - "43 Utah 84904\n", - "44 Vermont 9615\n", - "45 Virginia 42769\n", - "46 Washington 71303\n", - "47 West Virginia 24231\n", - "48 Wisconsin 65503\n", - "49 Wyoming 97818\n", - "50 District of Columbia 68\n", - "51 Puerto Rico 3515" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 美国各州的面积\n", - "areas = pd.read_csv('./state-areas.csv')\n", - "areas" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(52, 2)" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "areas.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          stateabbreviation
          0AlabamaAL
          1AlaskaAK
          2ArizonaAZ
          3ArkansasAR
          4CaliforniaCA
          5ColoradoCO
          6ConnecticutCT
          7DelawareDE
          8District of ColumbiaDC
          9FloridaFL
          10GeorgiaGA
          11HawaiiHI
          12IdahoID
          13IllinoisIL
          14IndianaIN
          15IowaIA
          16KansasKS
          17KentuckyKY
          18LouisianaLA
          19MaineME
          20MontanaMT
          21NebraskaNE
          22NevadaNV
          23New HampshireNH
          24New JerseyNJ
          25New MexicoNM
          26New YorkNY
          27North CarolinaNC
          28North DakotaND
          29OhioOH
          30OklahomaOK
          31OregonOR
          32MarylandMD
          33MassachusettsMA
          34MichiganMI
          35MinnesotaMN
          36MississippiMS
          37MissouriMO
          38PennsylvaniaPA
          39Rhode IslandRI
          40South CarolinaSC
          41South DakotaSD
          42TennesseeTN
          43TexasTX
          44UtahUT
          45VermontVT
          46VirginiaVA
          47WashingtonWA
          48West VirginiaWV
          49WisconsinWI
          50WyomingWY
          \n", - "
          " - ], - "text/plain": [ - " state abbreviation\n", - "0 Alabama AL\n", - "1 Alaska AK\n", - "2 Arizona AZ\n", - "3 Arkansas AR\n", - "4 California CA\n", - "5 Colorado CO\n", - "6 Connecticut CT\n", - "7 Delaware DE\n", - "8 District of Columbia DC\n", - "9 Florida FL\n", - "10 Georgia GA\n", - "11 Hawaii HI\n", - "12 Idaho ID\n", - "13 Illinois IL\n", - "14 Indiana IN\n", - "15 Iowa IA\n", - "16 Kansas KS\n", - "17 Kentucky KY\n", - "18 Louisiana LA\n", - "19 Maine ME\n", - "20 Montana MT\n", - "21 Nebraska NE\n", - "22 Nevada NV\n", - "23 New Hampshire NH\n", - "24 New Jersey NJ\n", - "25 New Mexico NM\n", - "26 New York NY\n", - "27 North Carolina NC\n", - "28 North Dakota ND\n", - "29 Ohio OH\n", - "30 Oklahoma OK\n", - "31 Oregon OR\n", - "32 Maryland MD\n", - "33 Massachusetts MA\n", - "34 Michigan MI\n", - "35 Minnesota MN\n", - "36 Mississippi MS\n", - "37 Missouri MO\n", - "38 Pennsylvania PA\n", - "39 Rhode Island RI\n", - "40 South Carolina SC\n", - "41 South Dakota SD\n", - "42 Tennessee TN\n", - "43 Texas TX\n", - "44 Utah UT\n", - "45 Vermont VT\n", - "46 Virginia VA\n", - "47 Washington WA\n", - "48 West Virginia WV\n", - "49 Wisconsin WI\n", - "50 Wyoming WY" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 美国各州 缩写\n", - "abbrevs = pd.read_csv('./state-abbrevs.csv')\n", - "abbrevs" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(51, 2)" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "abbrevs.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulation
          0ALunder1820121117489.0
          1ALtotal20124817528.0
          2ALunder1820101130966.0
          3ALtotal20104785570.0
          4ALunder1820111125763.0
          5ALtotal20114801627.0
          6ALtotal20094757938.0
          7ALunder1820091134192.0
          8ALunder1820131111481.0
          9ALtotal20134833722.0
          10ALtotal20074672840.0
          11ALunder1820071132296.0
          12ALtotal20084718206.0
          13ALunder1820081134927.0
          14ALtotal20054569805.0
          15ALunder1820051117229.0
          16ALtotal20064628981.0
          17ALunder1820061126798.0
          18ALtotal20044530729.0
          19ALunder1820041113662.0
          20ALtotal20034503491.0
          21ALunder1820031113083.0
          22ALtotal20014467634.0
          23ALunder1820011120409.0
          24ALtotal20024480089.0
          25ALunder1820021116590.0
          26ALunder1819991121287.0
          27ALtotal19994430141.0
          28ALtotal20004452173.0
          29ALunder1820001122273.0
          ...............
          2514USAunder18199971946051.0
          2515USAtotal2000282162411.0
          2516USAunder18200072376189.0
          2517USAtotal1999279040181.0
          2518USAtotal2001284968955.0
          2519USAunder18200172671175.0
          2520USAtotal2002287625193.0
          2521USAunder18200272936457.0
          2522USAtotal2003290107933.0
          2523USAunder18200373100758.0
          2524USAtotal2004292805298.0
          2525USAunder18200473297735.0
          2526USAtotal2005295516599.0
          2527USAunder18200573523669.0
          2528USAtotal2006298379912.0
          2529USAunder18200673757714.0
          2530USAtotal2007301231207.0
          2531USAunder18200774019405.0
          2532USAtotal2008304093966.0
          2533USAunder18200874104602.0
          2534USAunder18201373585872.0
          2535USAtotal2013316128839.0
          2536USAtotal2009306771529.0
          2537USAunder18200974134167.0
          2538USAunder18201074119556.0
          2539USAtotal2010309326295.0
          2540USAunder18201173902222.0
          2541USAtotal2011311582564.0
          2542USAunder18201273708179.0
          2543USAtotal2012313873685.0
          \n", - "

          2544 rows × 4 columns

          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population\n", - "0 AL under18 2012 1117489.0\n", - "1 AL total 2012 4817528.0\n", - "2 AL under18 2010 1130966.0\n", - "3 AL total 2010 4785570.0\n", - "4 AL under18 2011 1125763.0\n", - "5 AL total 2011 4801627.0\n", - "6 AL total 2009 4757938.0\n", - "7 AL under18 2009 1134192.0\n", - "8 AL under18 2013 1111481.0\n", - "9 AL total 2013 4833722.0\n", - "10 AL total 2007 4672840.0\n", - "11 AL under18 2007 1132296.0\n", - "12 AL total 2008 4718206.0\n", - "13 AL under18 2008 1134927.0\n", - "14 AL total 2005 4569805.0\n", - "15 AL under18 2005 1117229.0\n", - "16 AL total 2006 4628981.0\n", - "17 AL under18 2006 1126798.0\n", - "18 AL total 2004 4530729.0\n", - "19 AL under18 2004 1113662.0\n", - "20 AL total 2003 4503491.0\n", - "21 AL under18 2003 1113083.0\n", - "22 AL total 2001 4467634.0\n", - "23 AL under18 2001 1120409.0\n", - "24 AL total 2002 4480089.0\n", - "25 AL under18 2002 1116590.0\n", - "26 AL under18 1999 1121287.0\n", - "27 AL total 1999 4430141.0\n", - "28 AL total 2000 4452173.0\n", - "29 AL under18 2000 1122273.0\n", - "... ... ... ... ...\n", - "2514 USA under18 1999 71946051.0\n", - "2515 USA total 2000 282162411.0\n", - "2516 USA under18 2000 72376189.0\n", - "2517 USA total 1999 279040181.0\n", - "2518 USA total 2001 284968955.0\n", - "2519 USA under18 2001 72671175.0\n", - "2520 USA total 2002 287625193.0\n", - "2521 USA under18 2002 72936457.0\n", - "2522 USA total 2003 290107933.0\n", - "2523 USA under18 2003 73100758.0\n", - "2524 USA total 2004 292805298.0\n", - "2525 USA under18 2004 73297735.0\n", - "2526 USA total 2005 295516599.0\n", - "2527 USA under18 2005 73523669.0\n", - "2528 USA total 2006 298379912.0\n", - "2529 USA under18 2006 73757714.0\n", - "2530 USA total 2007 301231207.0\n", - "2531 USA under18 2007 74019405.0\n", - "2532 USA total 2008 304093966.0\n", - "2533 USA under18 2008 74104602.0\n", - "2534 USA under18 2013 73585872.0\n", - "2535 USA total 2013 316128839.0\n", - "2536 USA total 2009 306771529.0\n", - "2537 USA under18 2009 74134167.0\n", - "2538 USA under18 2010 74119556.0\n", - "2539 USA total 2010 309326295.0\n", - "2540 USA under18 2011 73902222.0\n", - "2541 USA total 2011 311582564.0\n", - "2542 USA under18 2012 73708179.0\n", - "2543 USA total 2012 313873685.0\n", - "\n", - "[2544 rows x 4 columns]" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 美国的人口数据\n", - "pop = pd.read_csv('./state-population.csv')\n", - "pop" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2544, 4)" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulation
          0ALunder1820121117489.0
          1ALtotal20124817528.0
          2ALunder1820101130966.0
          3ALtotal20104785570.0
          4ALunder1820111125763.0
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population\n", - "0 AL under18 2012 1117489.0\n", - "1 AL total 2012 4817528.0\n", - "2 AL under18 2010 1130966.0\n", - "3 AL total 2010 4785570.0\n", - "4 AL under18 2011 1125763.0" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          stateabbreviation
          0AlabamaAL
          1AlaskaAK
          2ArizonaAZ
          3ArkansasAR
          4CaliforniaCA
          \n", - "
          " - ], - "text/plain": [ - " state abbreviation\n", - "0 Alabama AL\n", - "1 Alaska AK\n", - "2 Arizona AZ\n", - "3 Arkansas AR\n", - "4 California CA" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "abbrevs.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(2544, 4)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "(51, 2)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "display(pop.shape,abbrevs.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(2544, 6)" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 级联时,数据变少了96个,哪些数据变少\n", - "# inner内连接,outer叫做外连接\n", - "pop2 = pop.merge(abbrevs,how = 'outer',left_on='state/region',right_on='abbreviation')\n", - "pop2.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region False\n", - "ages False\n", - "year False\n", - "population True\n", - "state True\n", - "abbreviation True\n", - "dtype: bool" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 前三列没有空值\n", - "pop2.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstateabbreviation
          0ALunder1820121117489.0AlabamaAL
          1ALtotal20124817528.0AlabamaAL
          2ALunder1820101130966.0AlabamaAL
          3ALtotal20104785570.0AlabamaAL
          4ALunder1820111125763.0AlabamaAL
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state abbreviation\n", - "0 AL under18 2012 1117489.0 Alabama AL\n", - "1 AL total 2012 4817528.0 Alabama AL\n", - "2 AL under18 2010 1130966.0 Alabama AL\n", - "3 AL total 2010 4785570.0 Alabama AL\n", - "4 AL under18 2011 1125763.0 Alabama AL" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "# 删除一列\n", - "pop2.drop(labels = 'abbreviation',axis = 1,inplace=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstate
          0ALunder1820121117489.0Alabama
          1ALtotal20124817528.0Alabama
          2ALunder1820101130966.0Alabama
          3ALtotal20104785570.0Alabama
          4ALunder1820111125763.0Alabama
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state\n", - "0 AL under18 2012 1117489.0 Alabama\n", - "1 AL total 2012 4817528.0 Alabama\n", - "2 AL under18 2010 1130966.0 Alabama\n", - "3 AL total 2010 4785570.0 Alabama\n", - "4 AL under18 2011 1125763.0 Alabama" - ] - }, - "execution_count": 21, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region False\n", - "ages False\n", - "year False\n", - "population True\n", - "state True\n", - "dtype: bool" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 False\n", - "1 False\n", - "2 False\n", - "3 False\n", - "4 False\n", - "5 False\n", - "6 False\n", - "7 False\n", - "8 False\n", - "9 False\n", - "10 False\n", - "11 False\n", - "12 False\n", - "13 False\n", - "14 False\n", - "15 False\n", - "16 False\n", - "17 False\n", - "18 False\n", - "19 False\n", - "20 False\n", - "21 False\n", - "22 False\n", - "23 False\n", - "24 False\n", - "25 False\n", - "26 False\n", - "27 False\n", - "28 False\n", - "29 False\n", - " ... \n", - "2514 True\n", - "2515 True\n", - "2516 True\n", - "2517 True\n", - "2518 True\n", - "2519 True\n", - "2520 True\n", - "2521 True\n", - "2522 True\n", - "2523 True\n", - "2524 True\n", - "2525 True\n", - "2526 True\n", - "2527 True\n", - "2528 True\n", - "2529 True\n", - "2530 True\n", - "2531 True\n", - "2532 True\n", - "2533 True\n", - "2534 True\n", - "2535 True\n", - "2536 True\n", - "2537 True\n", - "2538 True\n", - "2539 True\n", - "2540 True\n", - "2541 True\n", - "2542 True\n", - "2543 True\n", - "Name: state, Length: 2544, dtype: bool" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 定位为空的数据\n", - "cond = pop2['state'].isnull()\n", - "cond" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array(['PR', 'USA'], dtype=object)" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 只有当state为空,返回,为空时True\n", - "# 去重操作,非重复值\n", - "pop2[cond]['state/region'].unique()" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(51, 2)" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "abbrevs.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(52, 2)" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "areas.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          statearea (sq. mi)
          0Alabama52423
          1Alaska656425
          2Arizona114006
          3Arkansas53182
          4California163707
          5Colorado104100
          6Connecticut5544
          7Delaware1954
          8Florida65758
          9Georgia59441
          10Hawaii10932
          11Idaho83574
          12Illinois57918
          13Indiana36420
          14Iowa56276
          15Kansas82282
          16Kentucky40411
          17Louisiana51843
          18Maine35387
          19Maryland12407
          20Massachusetts10555
          21Michigan96810
          22Minnesota86943
          23Mississippi48434
          24Missouri69709
          25Montana147046
          26Nebraska77358
          27Nevada110567
          28New Hampshire9351
          29New Jersey8722
          30New Mexico121593
          31New York54475
          32North Carolina53821
          33North Dakota70704
          34Ohio44828
          35Oklahoma69903
          36Oregon98386
          37Pennsylvania46058
          38Rhode Island1545
          39South Carolina32007
          40South Dakota77121
          41Tennessee42146
          42Texas268601
          43Utah84904
          44Vermont9615
          45Virginia42769
          46Washington71303
          47West Virginia24231
          48Wisconsin65503
          49Wyoming97818
          50District of Columbia68
          51Puerto Rico3515
          \n", - "
          " - ], - "text/plain": [ - " state area (sq. mi)\n", - "0 Alabama 52423\n", - "1 Alaska 656425\n", - "2 Arizona 114006\n", - "3 Arkansas 53182\n", - "4 California 163707\n", - "5 Colorado 104100\n", - "6 Connecticut 5544\n", - "7 Delaware 1954\n", - "8 Florida 65758\n", - "9 Georgia 59441\n", - "10 Hawaii 10932\n", - "11 Idaho 83574\n", - "12 Illinois 57918\n", - "13 Indiana 36420\n", - "14 Iowa 56276\n", - "15 Kansas 82282\n", - "16 Kentucky 40411\n", - "17 Louisiana 51843\n", - "18 Maine 35387\n", - "19 Maryland 12407\n", - "20 Massachusetts 10555\n", - "21 Michigan 96810\n", - "22 Minnesota 86943\n", - "23 Mississippi 48434\n", - "24 Missouri 69709\n", - "25 Montana 147046\n", - "26 Nebraska 77358\n", - "27 Nevada 110567\n", - "28 New Hampshire 9351\n", - "29 New Jersey 8722\n", - "30 New Mexico 121593\n", - "31 New York 54475\n", - "32 North Carolina 53821\n", - "33 North Dakota 70704\n", - "34 Ohio 44828\n", - "35 Oklahoma 69903\n", - "36 Oregon 98386\n", - "37 Pennsylvania 46058\n", - "38 Rhode Island 1545\n", - "39 South Carolina 32007\n", - "40 South Dakota 77121\n", - "41 Tennessee 42146\n", - "42 Texas 268601\n", - "43 Utah 84904\n", - "44 Vermont 9615\n", - "45 Virginia 42769\n", - "46 Washington 71303\n", - "47 West Virginia 24231\n", - "48 Wisconsin 65503\n", - "49 Wyoming 97818\n", - "50 District of Columbia 68\n", - "51 Puerto Rico 3515" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "areas" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 False\n", - "1 False\n", - "2 False\n", - "3 False\n", - "4 False\n", - "5 False\n", - "6 False\n", - "7 False\n", - "8 False\n", - "9 False\n", - "10 False\n", - "11 False\n", - "12 False\n", - "13 False\n", - "14 False\n", - "15 False\n", - "16 False\n", - "17 False\n", - "18 False\n", - "19 False\n", - "20 False\n", - "21 False\n", - "22 False\n", - "23 False\n", - "24 False\n", - "25 False\n", - "26 False\n", - "27 False\n", - "28 False\n", - "29 False\n", - " ... \n", - "2514 False\n", - "2515 False\n", - "2516 False\n", - "2517 False\n", - "2518 False\n", - "2519 False\n", - "2520 False\n", - "2521 False\n", - "2522 False\n", - "2523 False\n", - "2524 False\n", - "2525 False\n", - "2526 False\n", - "2527 False\n", - "2528 False\n", - "2529 False\n", - "2530 False\n", - "2531 False\n", - "2532 False\n", - "2533 False\n", - "2534 False\n", - "2535 False\n", - "2536 False\n", - "2537 False\n", - "2538 False\n", - "2539 False\n", - "2540 False\n", - "2541 False\n", - "2542 False\n", - "2543 False\n", - "Name: state/region, Length: 2544, dtype: bool" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cond = pop2['state/region'] == 'PR'\n", - "cond" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:1: SettingWithCopyWarning: \n", - "A value is trying to be set on a copy of a slice from a DataFrame\n", - "\n", - "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", - " \"\"\"Entry point for launching an IPython kernel.\n" - ] - } - ], - "source": [ - "pop2['state'][cond] = 'Puerto Rico'" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:2: SettingWithCopyWarning: \n", - "A value is trying to be set on a copy of a slice from a DataFrame\n", - "\n", - "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", - " \n" - ] - } - ], - "source": [ - "cond = pop2['state/region'] == 'USA'\n", - "pop2['state'][cond] = 'United State'" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region False\n", - "ages False\n", - "year False\n", - "population True\n", - "state False\n", - "dtype: bool" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(20, 5)" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cond = pop2['population'].isnull()\n", - "pop2[cond].shape" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2544, 5)" - ] - }, - "execution_count": 43, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [], - "source": [ - "# 将难于进行补全的空数据进行删除\n", - "pop2.dropna(inplace=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2524, 5)" - ] - }, - "execution_count": 46, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region False\n", - "ages False\n", - "year False\n", - "population False\n", - "state False\n", - "dtype: bool" - ] - }, - "execution_count": 47, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region True\n", - "ages True\n", - "year True\n", - "population True\n", - "state True\n", - "dtype: bool" - ] - }, - "execution_count": 48, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.notnull().all()" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          statearea (sq. mi)
          0Alabama52423
          1Alaska656425
          2Arizona114006
          3Arkansas53182
          4California163707
          \n", - "
          " - ], - "text/plain": [ - " state area (sq. mi)\n", - "0 Alabama 52423\n", - "1 Alaska 656425\n", - "2 Arizona 114006\n", - "3 Arkansas 53182\n", - "4 California 163707" - ] - }, - "execution_count": 50, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "areas.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": { - "scrolled": false - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstate
          0ALunder1820121117489.0Alabama
          1ALtotal20124817528.0Alabama
          2ALunder1820101130966.0Alabama
          3ALtotal20104785570.0Alabama
          4ALunder1820111125763.0Alabama
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state\n", - "0 AL under18 2012 1117489.0 Alabama\n", - "1 AL total 2012 4817528.0 Alabama\n", - "2 AL under18 2010 1130966.0 Alabama\n", - "3 AL total 2010 4785570.0 Alabama\n", - "4 AL under18 2011 1125763.0 Alabama" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop2.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2524, 6)" - ] - }, - "execution_count": 51, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop3 = pop2.merge(areas,how = 'outer')\n", - "pop3.shape" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstatearea (sq. mi)
          0ALunder1820121117489.0Alabama52423.0
          1ALtotal20124817528.0Alabama52423.0
          2ALunder1820101130966.0Alabama52423.0
          3ALtotal20104785570.0Alabama52423.0
          4ALunder1820111125763.0Alabama52423.0
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state area (sq. mi)\n", - "0 AL under18 2012 1117489.0 Alabama 52423.0\n", - "1 AL total 2012 4817528.0 Alabama 52423.0\n", - "2 AL under18 2010 1130966.0 Alabama 52423.0\n", - "3 AL total 2010 4785570.0 Alabama 52423.0\n", - "4 AL under18 2011 1125763.0 Alabama 52423.0" - ] - }, - "execution_count": 52, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop3.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region False\n", - "ages False\n", - "year False\n", - "population False\n", - "state False\n", - "area (sq. mi) True\n", - "dtype: bool" - ] - }, - "execution_count": 53, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop3.isnull().any()" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstatearea (sq. mi)
          2476USAunder18199064218512.0United StateNaN
          2477USAtotal1990249622814.0United StateNaN
          2478USAtotal1991252980942.0United StateNaN
          2479USAunder18199165313018.0United StateNaN
          2480USAunder18199266509177.0United StateNaN
          2481USAtotal1992256514231.0United StateNaN
          2482USAtotal1993259918595.0United StateNaN
          2483USAunder18199367594938.0United StateNaN
          2484USAunder18199468640936.0United StateNaN
          2485USAtotal1994263125826.0United StateNaN
          2486USAunder18199569473140.0United StateNaN
          2487USAunder18199670233512.0United StateNaN
          2488USAtotal1995266278403.0United StateNaN
          2489USAtotal1996269394291.0United StateNaN
          2490USAtotal1997272646932.0United StateNaN
          2491USAunder18199770920738.0United StateNaN
          2492USAunder18199871431406.0United StateNaN
          2493USAtotal1998275854116.0United StateNaN
          2494USAunder18199971946051.0United StateNaN
          2495USAtotal2000282162411.0United StateNaN
          2496USAunder18200072376189.0United StateNaN
          2497USAtotal1999279040181.0United StateNaN
          2498USAtotal2001284968955.0United StateNaN
          2499USAunder18200172671175.0United StateNaN
          2500USAtotal2002287625193.0United StateNaN
          2501USAunder18200272936457.0United StateNaN
          2502USAtotal2003290107933.0United StateNaN
          2503USAunder18200373100758.0United StateNaN
          2504USAtotal2004292805298.0United StateNaN
          2505USAunder18200473297735.0United StateNaN
          2506USAtotal2005295516599.0United StateNaN
          2507USAunder18200573523669.0United StateNaN
          2508USAtotal2006298379912.0United StateNaN
          2509USAunder18200673757714.0United StateNaN
          2510USAtotal2007301231207.0United StateNaN
          2511USAunder18200774019405.0United StateNaN
          2512USAtotal2008304093966.0United StateNaN
          2513USAunder18200874104602.0United StateNaN
          2514USAunder18201373585872.0United StateNaN
          2515USAtotal2013316128839.0United StateNaN
          2516USAtotal2009306771529.0United StateNaN
          2517USAunder18200974134167.0United StateNaN
          2518USAunder18201074119556.0United StateNaN
          2519USAtotal2010309326295.0United StateNaN
          2520USAunder18201173902222.0United StateNaN
          2521USAtotal2011311582564.0United StateNaN
          2522USAunder18201273708179.0United StateNaN
          2523USAtotal2012313873685.0United StateNaN
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state area (sq. mi)\n", - "2476 USA under18 1990 64218512.0 United State NaN\n", - "2477 USA total 1990 249622814.0 United State NaN\n", - "2478 USA total 1991 252980942.0 United State NaN\n", - "2479 USA under18 1991 65313018.0 United State NaN\n", - "2480 USA under18 1992 66509177.0 United State NaN\n", - "2481 USA total 1992 256514231.0 United State NaN\n", - "2482 USA total 1993 259918595.0 United State NaN\n", - "2483 USA under18 1993 67594938.0 United State NaN\n", - "2484 USA under18 1994 68640936.0 United State NaN\n", - "2485 USA total 1994 263125826.0 United State NaN\n", - "2486 USA under18 1995 69473140.0 United State NaN\n", - "2487 USA under18 1996 70233512.0 United State NaN\n", - "2488 USA total 1995 266278403.0 United State NaN\n", - "2489 USA total 1996 269394291.0 United State NaN\n", - "2490 USA total 1997 272646932.0 United State NaN\n", - "2491 USA under18 1997 70920738.0 United State NaN\n", - "2492 USA under18 1998 71431406.0 United State NaN\n", - "2493 USA total 1998 275854116.0 United State NaN\n", - "2494 USA under18 1999 71946051.0 United State NaN\n", - "2495 USA total 2000 282162411.0 United State NaN\n", - "2496 USA under18 2000 72376189.0 United State NaN\n", - "2497 USA total 1999 279040181.0 United State NaN\n", - "2498 USA total 2001 284968955.0 United State NaN\n", - "2499 USA under18 2001 72671175.0 United State NaN\n", - "2500 USA total 2002 287625193.0 United State NaN\n", - "2501 USA under18 2002 72936457.0 United State NaN\n", - "2502 USA total 2003 290107933.0 United State NaN\n", - "2503 USA under18 2003 73100758.0 United State NaN\n", - "2504 USA total 2004 292805298.0 United State NaN\n", - "2505 USA under18 2004 73297735.0 United State NaN\n", - "2506 USA total 2005 295516599.0 United State NaN\n", - "2507 USA under18 2005 73523669.0 United State NaN\n", - "2508 USA total 2006 298379912.0 United State NaN\n", - "2509 USA under18 2006 73757714.0 United State NaN\n", - "2510 USA total 2007 301231207.0 United State NaN\n", - "2511 USA under18 2007 74019405.0 United State NaN\n", - "2512 USA total 2008 304093966.0 United State NaN\n", - "2513 USA under18 2008 74104602.0 United State NaN\n", - "2514 USA under18 2013 73585872.0 United State NaN\n", - "2515 USA total 2013 316128839.0 United State NaN\n", - "2516 USA total 2009 306771529.0 United State NaN\n", - "2517 USA under18 2009 74134167.0 United State NaN\n", - "2518 USA under18 2010 74119556.0 United State NaN\n", - "2519 USA total 2010 309326295.0 United State NaN\n", - "2520 USA under18 2011 73902222.0 United State NaN\n", - "2521 USA total 2011 311582564.0 United State NaN\n", - "2522 USA under18 2012 73708179.0 United State NaN\n", - "2523 USA total 2012 313873685.0 United State NaN" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cond = pop3['area (sq. mi)'].isnull()\n", - "pop3[cond]" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "3790399" - ] - }, - "execution_count": 58, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "a = areas['area (sq. mi)'].sum()\n", - "a" - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "d:\\python36\\lib\\site-packages\\ipykernel_launcher.py:3: SettingWithCopyWarning: \n", - "A value is trying to be set on a copy of a slice from a DataFrame\n", - "\n", - "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n", - " This is separate from the ipykernel package so we can avoid doing imports until\n" - ] - } - ], - "source": [ - "cond = pop3['state'] == \"United State\"\n", - "\n", - "pop3['area (sq. mi)'][cond] = a" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "state/region True\n", - "ages True\n", - "year True\n", - "population True\n", - "state True\n", - "area (sq. mi) True\n", - "dtype: bool" - ] - }, - "execution_count": 61, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop3.notnull().all()" - ] - }, - { - "cell_type": "code", - "execution_count": 62, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstatearea (sq. mi)
          0ALunder1820121117489.0Alabama52423.0
          1ALtotal20124817528.0Alabama52423.0
          2ALunder1820101130966.0Alabama52423.0
          3ALtotal20104785570.0Alabama52423.0
          4ALunder1820111125763.0Alabama52423.0
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state area (sq. mi)\n", - "0 AL under18 2012 1117489.0 Alabama 52423.0\n", - "1 AL total 2012 4817528.0 Alabama 52423.0\n", - "2 AL under18 2010 1130966.0 Alabama 52423.0\n", - "3 AL total 2010 4785570.0 Alabama 52423.0\n", - "4 AL under18 2011 1125763.0 Alabama 52423.0" - ] - }, - "execution_count": 62, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop3.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "0 21.3\n", - "1 91.9\n", - "2 21.6\n", - "3 91.3\n", - "4 21.5\n", - "5 91.6\n", - "6 90.8\n", - "7 21.6\n", - "8 21.2\n", - "9 92.2\n", - "10 89.1\n", - "11 21.6\n", - "12 90.0\n", - "13 21.6\n", - "14 87.2\n", - "15 21.3\n", - "16 88.3\n", - "17 21.5\n", - "18 86.4\n", - "19 21.2\n", - "20 85.9\n", - "21 21.2\n", - "22 85.2\n", - "23 21.4\n", - "24 85.5\n", - "25 21.3\n", - "26 21.4\n", - "27 84.5\n", - "28 84.9\n", - "29 21.4\n", - " ... \n", - "2494 19.0\n", - "2495 74.4\n", - "2496 19.1\n", - "2497 73.6\n", - "2498 75.2\n", - "2499 19.2\n", - "2500 75.9\n", - "2501 19.2\n", - "2502 76.5\n", - "2503 19.3\n", - "2504 77.2\n", - "2505 19.3\n", - "2506 78.0\n", - "2507 19.4\n", - "2508 78.7\n", - "2509 19.5\n", - "2510 79.5\n", - "2511 19.5\n", - "2512 80.2\n", - "2513 19.6\n", - "2514 19.4\n", - "2515 83.4\n", - "2516 80.9\n", - "2517 19.6\n", - "2518 19.6\n", - "2519 81.6\n", - "2520 19.5\n", - "2521 82.2\n", - "2522 19.4\n", - "2523 82.8\n", - "Length: 2524, dtype: float64" - ] - }, - "execution_count": 66, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop_density = (pop3['population']/pop3['area (sq. mi)']).round(1)\n", - "pop_density" - ] - }, - { - "cell_type": "code", - "execution_count": 67, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          0
          021.3
          191.9
          221.6
          391.3
          421.5
          591.6
          690.8
          721.6
          821.2
          992.2
          1089.1
          1121.6
          1290.0
          1321.6
          1487.2
          1521.3
          1688.3
          1721.5
          1886.4
          1921.2
          2085.9
          2121.2
          2285.2
          2321.4
          2485.5
          2521.3
          2621.4
          2784.5
          2884.9
          2921.4
          ......
          249419.0
          249574.4
          249619.1
          249773.6
          249875.2
          249919.2
          250075.9
          250119.2
          250276.5
          250319.3
          250477.2
          250519.3
          250678.0
          250719.4
          250878.7
          250919.5
          251079.5
          251119.5
          251280.2
          251319.6
          251419.4
          251583.4
          251680.9
          251719.6
          251819.6
          251981.6
          252019.5
          252182.2
          252219.4
          252382.8
          \n", - "

          2524 rows × 1 columns

          \n", - "
          " - ], - "text/plain": [ - " 0\n", - "0 21.3\n", - "1 91.9\n", - "2 21.6\n", - "3 91.3\n", - "4 21.5\n", - "5 91.6\n", - "6 90.8\n", - "7 21.6\n", - "8 21.2\n", - "9 92.2\n", - "10 89.1\n", - "11 21.6\n", - "12 90.0\n", - "13 21.6\n", - "14 87.2\n", - "15 21.3\n", - "16 88.3\n", - "17 21.5\n", - "18 86.4\n", - "19 21.2\n", - "20 85.9\n", - "21 21.2\n", - "22 85.2\n", - "23 21.4\n", - "24 85.5\n", - "25 21.3\n", - "26 21.4\n", - "27 84.5\n", - "28 84.9\n", - "29 21.4\n", - "... ...\n", - "2494 19.0\n", - "2495 74.4\n", - "2496 19.1\n", - "2497 73.6\n", - "2498 75.2\n", - "2499 19.2\n", - "2500 75.9\n", - "2501 19.2\n", - "2502 76.5\n", - "2503 19.3\n", - "2504 77.2\n", - "2505 19.3\n", - "2506 78.0\n", - "2507 19.4\n", - "2508 78.7\n", - "2509 19.5\n", - "2510 79.5\n", - "2511 19.5\n", - "2512 80.2\n", - "2513 19.6\n", - "2514 19.4\n", - "2515 83.4\n", - "2516 80.9\n", - "2517 19.6\n", - "2518 19.6\n", - "2519 81.6\n", - "2520 19.5\n", - "2521 82.2\n", - "2522 19.4\n", - "2523 82.8\n", - "\n", - "[2524 rows x 1 columns]" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop_density = DataFrame(pop_density)\n", - "pop_density" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          pop_density
          021.3
          191.9
          221.6
          391.3
          421.5
          \n", - "
          " - ], - "text/plain": [ - " pop_density\n", - "0 21.3\n", - "1 91.9\n", - "2 21.6\n", - "3 91.3\n", - "4 21.5" - ] - }, - "execution_count": 68, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop_density.columns = ['pop_density']\n", - "pop_density.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 69, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstatearea (sq. mi)pop_density
          0ALunder1820121117489.0Alabama52423.021.3
          1ALtotal20124817528.0Alabama52423.091.9
          2ALunder1820101130966.0Alabama52423.021.6
          3ALtotal20104785570.0Alabama52423.091.3
          4ALunder1820111125763.0Alabama52423.021.5
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state area (sq. mi) pop_density\n", - "0 AL under18 2012 1117489.0 Alabama 52423.0 21.3\n", - "1 AL total 2012 4817528.0 Alabama 52423.0 91.9\n", - "2 AL under18 2010 1130966.0 Alabama 52423.0 21.6\n", - "3 AL total 2010 4785570.0 Alabama 52423.0 91.3\n", - "4 AL under18 2011 1125763.0 Alabama 52423.0 21.5" - ] - }, - "execution_count": 69, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop4 = pop3.merge(pop_density,left_index=True,right_index=True)\n", - "pop4.head()" - ] - }, - { - "cell_type": "code", - "execution_count": 70, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "data": { - "text/plain": [ - "array([2012, 2010, 2011, 2009, 2013, 2007, 2008, 2005, 2006, 2004, 2003,\n", - " 2001, 2002, 1999, 2000, 1998, 1997, 1996, 1995, 1994, 1993, 1992,\n", - " 1991, 1990], dtype=int64)" - ] - }, - "execution_count": 70, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop4['year'].unique()" - ] - }, - { - "cell_type": "code", - "execution_count": 71, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "array(['under18', 'total'], dtype=object)" - ] - }, - "execution_count": 71, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop4['ages'].unique()" - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          state/regionagesyearpopulationstatearea (sq. mi)pop_density
          1ALtotal20124817528.0Alabama52423.091.9
          95AKtotal2012730307.0Alaska656425.01.1
          97AZtotal20126551149.0Arizona114006.057.5
          191ARtotal20122949828.0Arkansas53182.055.5
          193CAtotal201237999878.0California163707.0232.1
          287COtotal20125189458.0Colorado104100.049.9
          289CTtotal20123591765.0Connecticut5544.0647.9
          383DEtotal2012917053.0Delaware1954.0469.3
          385DCtotal2012633427.0District of Columbia68.09315.1
          479FLtotal201219320749.0Florida65758.0293.8
          480GAtotal20129915646.0Georgia59441.0166.8
          575HItotal20121390090.0Hawaii10932.0127.2
          576IDtotal20121595590.0Idaho83574.019.1
          671ILtotal201212868192.0Illinois57918.0222.2
          672INtotal20126537782.0Indiana36420.0179.5
          767IAtotal20123075039.0Iowa56276.054.6
          768KStotal20122885398.0Kansas82282.035.1
          863KYtotal20124379730.0Kentucky40411.0108.4
          864LAtotal20124602134.0Louisiana51843.088.8
          959MEtotal20121328501.0Maine35387.037.5
          960MDtotal20125884868.0Maryland12407.0474.3
          1055MAtotal20126645303.0Massachusetts10555.0629.6
          1056MItotal20129882519.0Michigan96810.0102.1
          1151MNtotal20125379646.0Minnesota86943.061.9
          1152MStotal20122986450.0Mississippi48434.061.7
          1247MOtotal20126024522.0Missouri69709.086.4
          1248MTtotal20121005494.0Montana147046.06.8
          1343NEtotal20121855350.0Nebraska77358.024.0
          1344NVtotal20122754354.0Nevada110567.024.9
          1439NHtotal20121321617.0New Hampshire9351.0141.3
          1440NJtotal20128867749.0New Jersey8722.01016.7
          1535NMtotal20122083540.0New Mexico121593.017.1
          1536NYtotal201219576125.0New York54475.0359.4
          1631NCtotal20129748364.0North Carolina53821.0181.1
          1632NDtotal2012701345.0North Dakota70704.09.9
          1727OHtotal201211553031.0Ohio44828.0257.7
          1728OKtotal20123815780.0Oklahoma69903.054.6
          1823ORtotal20123899801.0Oregon98386.039.6
          1824PAtotal201212764475.0Pennsylvania46058.0277.1
          1919RItotal20121050304.0Rhode Island1545.0679.8
          1920SCtotal20124723417.0South Carolina32007.0147.6
          2015SDtotal2012834047.0South Dakota77121.010.8
          2016TNtotal20126454914.0Tennessee42146.0153.2
          2111TXtotal201226060796.0Texas268601.097.0
          2112UTtotal20122854871.0Utah84904.033.6
          2207VTtotal2012625953.0Vermont9615.065.1
          2208VAtotal20128186628.0Virginia42769.0191.4
          2303WAtotal20126895318.0Washington71303.096.7
          2304WVtotal20121856680.0West Virginia24231.076.6
          2399WItotal20125724554.0Wisconsin65503.087.4
          2400WYtotal2012576626.0Wyoming97818.05.9
          2475PRtotal20123651545.0Puerto Rico3515.01038.8
          2523USAtotal2012313873685.0United State3790399.082.8
          \n", - "
          " - ], - "text/plain": [ - " state/region ages year population state area (sq. mi) pop_density\n", - "1 AL total 2012 4817528.0 Alabama 52423.0 91.9\n", - "95 AK total 2012 730307.0 Alaska 656425.0 1.1\n", - "97 AZ total 2012 6551149.0 Arizona 114006.0 57.5\n", - "191 AR total 2012 2949828.0 Arkansas 53182.0 55.5\n", - "193 CA total 2012 37999878.0 California 163707.0 232.1\n", - "287 CO total 2012 5189458.0 Colorado 104100.0 49.9\n", - "289 CT total 2012 3591765.0 Connecticut 5544.0 647.9\n", - "383 DE total 2012 917053.0 Delaware 1954.0 469.3\n", - "385 DC total 2012 633427.0 District of Columbia 68.0 9315.1\n", - "479 FL total 2012 19320749.0 Florida 65758.0 293.8\n", - "480 GA total 2012 9915646.0 Georgia 59441.0 166.8\n", - "575 HI total 2012 1390090.0 Hawaii 10932.0 127.2\n", - "576 ID total 2012 1595590.0 Idaho 83574.0 19.1\n", - "671 IL total 2012 12868192.0 Illinois 57918.0 222.2\n", - "672 IN total 2012 6537782.0 Indiana 36420.0 179.5\n", - "767 IA total 2012 3075039.0 Iowa 56276.0 54.6\n", - "768 KS total 2012 2885398.0 Kansas 82282.0 35.1\n", - "863 KY total 2012 4379730.0 Kentucky 40411.0 108.4\n", - "864 LA total 2012 4602134.0 Louisiana 51843.0 88.8\n", - "959 ME total 2012 1328501.0 Maine 35387.0 37.5\n", - "960 MD total 2012 5884868.0 Maryland 12407.0 474.3\n", - "1055 MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n", - "1056 MI total 2012 9882519.0 Michigan 96810.0 102.1\n", - "1151 MN total 2012 5379646.0 Minnesota 86943.0 61.9\n", - "1152 MS total 2012 2986450.0 Mississippi 48434.0 61.7\n", - "1247 MO total 2012 6024522.0 Missouri 69709.0 86.4\n", - "1248 MT total 2012 1005494.0 Montana 147046.0 6.8\n", - "1343 NE total 2012 1855350.0 Nebraska 77358.0 24.0\n", - "1344 NV total 2012 2754354.0 Nevada 110567.0 24.9\n", - "1439 NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n", - "1440 NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n", - "1535 NM total 2012 2083540.0 New Mexico 121593.0 17.1\n", - "1536 NY total 2012 19576125.0 New York 54475.0 359.4\n", - "1631 NC total 2012 9748364.0 North Carolina 53821.0 181.1\n", - "1632 ND total 2012 701345.0 North Dakota 70704.0 9.9\n", - "1727 OH total 2012 11553031.0 Ohio 44828.0 257.7\n", - "1728 OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n", - "1823 OR total 2012 3899801.0 Oregon 98386.0 39.6\n", - "1824 PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n", - "1919 RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n", - "1920 SC total 2012 4723417.0 South Carolina 32007.0 147.6\n", - "2015 SD total 2012 834047.0 South Dakota 77121.0 10.8\n", - "2016 TN total 2012 6454914.0 Tennessee 42146.0 153.2\n", - "2111 TX total 2012 26060796.0 Texas 268601.0 97.0\n", - "2112 UT total 2012 2854871.0 Utah 84904.0 33.6\n", - "2207 VT total 2012 625953.0 Vermont 9615.0 65.1\n", - "2208 VA total 2012 8186628.0 Virginia 42769.0 191.4\n", - "2303 WA total 2012 6895318.0 Washington 71303.0 96.7\n", - "2304 WV total 2012 1856680.0 West Virginia 24231.0 76.6\n", - "2399 WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n", - "2400 WY total 2012 576626.0 Wyoming 97818.0 5.9\n", - "2475 PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n", - "2523 USA total 2012 313873685.0 United State 3790399.0 82.8" - ] - }, - "execution_count": 73, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# 查找2012年美国各州的全民人口数据\n", - "\n", - "# pandas非常强大的,可以像查询数据库一样进行数据查询\n", - "\n", - "pop5 = pop4.query(\"year == 2012 and ages == 'total'\")\n", - "pop5" - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "metadata": {}, - "outputs": [], - "source": [ - "pop5.set_index(keys = 'state/region',inplace=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 80, - "metadata": { - "collapsed": true - }, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          agesyearpopulationstatearea (sq. mi)pop_density
          state/region
          AKtotal2012730307.0Alaska656425.01.1
          WYtotal2012576626.0Wyoming97818.05.9
          MTtotal20121005494.0Montana147046.06.8
          NDtotal2012701345.0North Dakota70704.09.9
          SDtotal2012834047.0South Dakota77121.010.8
          NMtotal20122083540.0New Mexico121593.017.1
          IDtotal20121595590.0Idaho83574.019.1
          NEtotal20121855350.0Nebraska77358.024.0
          NVtotal20122754354.0Nevada110567.024.9
          UTtotal20122854871.0Utah84904.033.6
          KStotal20122885398.0Kansas82282.035.1
          MEtotal20121328501.0Maine35387.037.5
          ORtotal20123899801.0Oregon98386.039.6
          COtotal20125189458.0Colorado104100.049.9
          IAtotal20123075039.0Iowa56276.054.6
          OKtotal20123815780.0Oklahoma69903.054.6
          ARtotal20122949828.0Arkansas53182.055.5
          AZtotal20126551149.0Arizona114006.057.5
          MStotal20122986450.0Mississippi48434.061.7
          MNtotal20125379646.0Minnesota86943.061.9
          VTtotal2012625953.0Vermont9615.065.1
          WVtotal20121856680.0West Virginia24231.076.6
          USAtotal2012313873685.0United State3790399.082.8
          MOtotal20126024522.0Missouri69709.086.4
          WItotal20125724554.0Wisconsin65503.087.4
          LAtotal20124602134.0Louisiana51843.088.8
          ALtotal20124817528.0Alabama52423.091.9
          WAtotal20126895318.0Washington71303.096.7
          TXtotal201226060796.0Texas268601.097.0
          MItotal20129882519.0Michigan96810.0102.1
          KYtotal20124379730.0Kentucky40411.0108.4
          HItotal20121390090.0Hawaii10932.0127.2
          NHtotal20121321617.0New Hampshire9351.0141.3
          SCtotal20124723417.0South Carolina32007.0147.6
          TNtotal20126454914.0Tennessee42146.0153.2
          GAtotal20129915646.0Georgia59441.0166.8
          INtotal20126537782.0Indiana36420.0179.5
          NCtotal20129748364.0North Carolina53821.0181.1
          VAtotal20128186628.0Virginia42769.0191.4
          ILtotal201212868192.0Illinois57918.0222.2
          CAtotal201237999878.0California163707.0232.1
          OHtotal201211553031.0Ohio44828.0257.7
          PAtotal201212764475.0Pennsylvania46058.0277.1
          FLtotal201219320749.0Florida65758.0293.8
          NYtotal201219576125.0New York54475.0359.4
          DEtotal2012917053.0Delaware1954.0469.3
          MDtotal20125884868.0Maryland12407.0474.3
          MAtotal20126645303.0Massachusetts10555.0629.6
          CTtotal20123591765.0Connecticut5544.0647.9
          RItotal20121050304.0Rhode Island1545.0679.8
          NJtotal20128867749.0New Jersey8722.01016.7
          PRtotal20123651545.0Puerto Rico3515.01038.8
          DCtotal2012633427.0District of Columbia68.09315.1
          \n", - "
          " - ], - "text/plain": [ - " ages year population state area (sq. mi) pop_density\n", - "state/region \n", - "AK total 2012 730307.0 Alaska 656425.0 1.1\n", - "WY total 2012 576626.0 Wyoming 97818.0 5.9\n", - "MT total 2012 1005494.0 Montana 147046.0 6.8\n", - "ND total 2012 701345.0 North Dakota 70704.0 9.9\n", - "SD total 2012 834047.0 South Dakota 77121.0 10.8\n", - "NM total 2012 2083540.0 New Mexico 121593.0 17.1\n", - "ID total 2012 1595590.0 Idaho 83574.0 19.1\n", - "NE total 2012 1855350.0 Nebraska 77358.0 24.0\n", - "NV total 2012 2754354.0 Nevada 110567.0 24.9\n", - "UT total 2012 2854871.0 Utah 84904.0 33.6\n", - "KS total 2012 2885398.0 Kansas 82282.0 35.1\n", - "ME total 2012 1328501.0 Maine 35387.0 37.5\n", - "OR total 2012 3899801.0 Oregon 98386.0 39.6\n", - "CO total 2012 5189458.0 Colorado 104100.0 49.9\n", - "IA total 2012 3075039.0 Iowa 56276.0 54.6\n", - "OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n", - "AR total 2012 2949828.0 Arkansas 53182.0 55.5\n", - "AZ total 2012 6551149.0 Arizona 114006.0 57.5\n", - "MS total 2012 2986450.0 Mississippi 48434.0 61.7\n", - "MN total 2012 5379646.0 Minnesota 86943.0 61.9\n", - "VT total 2012 625953.0 Vermont 9615.0 65.1\n", - "WV total 2012 1856680.0 West Virginia 24231.0 76.6\n", - "USA total 2012 313873685.0 United State 3790399.0 82.8\n", - "MO total 2012 6024522.0 Missouri 69709.0 86.4\n", - "WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n", - "LA total 2012 4602134.0 Louisiana 51843.0 88.8\n", - "AL total 2012 4817528.0 Alabama 52423.0 91.9\n", - "WA total 2012 6895318.0 Washington 71303.0 96.7\n", - "TX total 2012 26060796.0 Texas 268601.0 97.0\n", - "MI total 2012 9882519.0 Michigan 96810.0 102.1\n", - "KY total 2012 4379730.0 Kentucky 40411.0 108.4\n", - "HI total 2012 1390090.0 Hawaii 10932.0 127.2\n", - "NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n", - "SC total 2012 4723417.0 South Carolina 32007.0 147.6\n", - "TN total 2012 6454914.0 Tennessee 42146.0 153.2\n", - "GA total 2012 9915646.0 Georgia 59441.0 166.8\n", - "IN total 2012 6537782.0 Indiana 36420.0 179.5\n", - "NC total 2012 9748364.0 North Carolina 53821.0 181.1\n", - "VA total 2012 8186628.0 Virginia 42769.0 191.4\n", - "IL total 2012 12868192.0 Illinois 57918.0 222.2\n", - "CA total 2012 37999878.0 California 163707.0 232.1\n", - "OH total 2012 11553031.0 Ohio 44828.0 257.7\n", - "PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n", - "FL total 2012 19320749.0 Florida 65758.0 293.8\n", - "NY total 2012 19576125.0 New York 54475.0 359.4\n", - "DE total 2012 917053.0 Delaware 1954.0 469.3\n", - "MD total 2012 5884868.0 Maryland 12407.0 474.3\n", - "MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n", - "CT total 2012 3591765.0 Connecticut 5544.0 647.9\n", - "RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n", - "NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n", - "PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n", - "DC total 2012 633427.0 District of Columbia 68.0 9315.1" - ] - }, - "execution_count": 80, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop5.sort_values(by = 'pop_density')" - ] - }, - { - "cell_type": "code", - "execution_count": 81, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
          \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
          agesyearpopulationstatearea (sq. mi)pop_density
          state/region
          DCtotal2012633427.0District of Columbia68.09315.1
          PRtotal20123651545.0Puerto Rico3515.01038.8
          NJtotal20128867749.0New Jersey8722.01016.7
          RItotal20121050304.0Rhode Island1545.0679.8
          CTtotal20123591765.0Connecticut5544.0647.9
          MAtotal20126645303.0Massachusetts10555.0629.6
          MDtotal20125884868.0Maryland12407.0474.3
          DEtotal2012917053.0Delaware1954.0469.3
          NYtotal201219576125.0New York54475.0359.4
          FLtotal201219320749.0Florida65758.0293.8
          PAtotal201212764475.0Pennsylvania46058.0277.1
          OHtotal201211553031.0Ohio44828.0257.7
          CAtotal201237999878.0California163707.0232.1
          ILtotal201212868192.0Illinois57918.0222.2
          VAtotal20128186628.0Virginia42769.0191.4
          NCtotal20129748364.0North Carolina53821.0181.1
          INtotal20126537782.0Indiana36420.0179.5
          GAtotal20129915646.0Georgia59441.0166.8
          TNtotal20126454914.0Tennessee42146.0153.2
          SCtotal20124723417.0South Carolina32007.0147.6
          NHtotal20121321617.0New Hampshire9351.0141.3
          HItotal20121390090.0Hawaii10932.0127.2
          KYtotal20124379730.0Kentucky40411.0108.4
          MItotal20129882519.0Michigan96810.0102.1
          TXtotal201226060796.0Texas268601.097.0
          WAtotal20126895318.0Washington71303.096.7
          ALtotal20124817528.0Alabama52423.091.9
          LAtotal20124602134.0Louisiana51843.088.8
          WItotal20125724554.0Wisconsin65503.087.4
          MOtotal20126024522.0Missouri69709.086.4
          USAtotal2012313873685.0United State3790399.082.8
          WVtotal20121856680.0West Virginia24231.076.6
          VTtotal2012625953.0Vermont9615.065.1
          MNtotal20125379646.0Minnesota86943.061.9
          MStotal20122986450.0Mississippi48434.061.7
          AZtotal20126551149.0Arizona114006.057.5
          ARtotal20122949828.0Arkansas53182.055.5
          OKtotal20123815780.0Oklahoma69903.054.6
          IAtotal20123075039.0Iowa56276.054.6
          COtotal20125189458.0Colorado104100.049.9
          ORtotal20123899801.0Oregon98386.039.6
          MEtotal20121328501.0Maine35387.037.5
          KStotal20122885398.0Kansas82282.035.1
          UTtotal20122854871.0Utah84904.033.6
          NVtotal20122754354.0Nevada110567.024.9
          NEtotal20121855350.0Nebraska77358.024.0
          IDtotal20121595590.0Idaho83574.019.1
          NMtotal20122083540.0New Mexico121593.017.1
          SDtotal2012834047.0South Dakota77121.010.8
          NDtotal2012701345.0North Dakota70704.09.9
          MTtotal20121005494.0Montana147046.06.8
          WYtotal2012576626.0Wyoming97818.05.9
          AKtotal2012730307.0Alaska656425.01.1
          \n", - "
          " - ], - "text/plain": [ - " ages year population state area (sq. mi) pop_density\n", - "state/region \n", - "DC total 2012 633427.0 District of Columbia 68.0 9315.1\n", - "PR total 2012 3651545.0 Puerto Rico 3515.0 1038.8\n", - "NJ total 2012 8867749.0 New Jersey 8722.0 1016.7\n", - "RI total 2012 1050304.0 Rhode Island 1545.0 679.8\n", - "CT total 2012 3591765.0 Connecticut 5544.0 647.9\n", - "MA total 2012 6645303.0 Massachusetts 10555.0 629.6\n", - "MD total 2012 5884868.0 Maryland 12407.0 474.3\n", - "DE total 2012 917053.0 Delaware 1954.0 469.3\n", - "NY total 2012 19576125.0 New York 54475.0 359.4\n", - "FL total 2012 19320749.0 Florida 65758.0 293.8\n", - "PA total 2012 12764475.0 Pennsylvania 46058.0 277.1\n", - "OH total 2012 11553031.0 Ohio 44828.0 257.7\n", - "CA total 2012 37999878.0 California 163707.0 232.1\n", - "IL total 2012 12868192.0 Illinois 57918.0 222.2\n", - "VA total 2012 8186628.0 Virginia 42769.0 191.4\n", - "NC total 2012 9748364.0 North Carolina 53821.0 181.1\n", - "IN total 2012 6537782.0 Indiana 36420.0 179.5\n", - "GA total 2012 9915646.0 Georgia 59441.0 166.8\n", - "TN total 2012 6454914.0 Tennessee 42146.0 153.2\n", - "SC total 2012 4723417.0 South Carolina 32007.0 147.6\n", - "NH total 2012 1321617.0 New Hampshire 9351.0 141.3\n", - "HI total 2012 1390090.0 Hawaii 10932.0 127.2\n", - "KY total 2012 4379730.0 Kentucky 40411.0 108.4\n", - "MI total 2012 9882519.0 Michigan 96810.0 102.1\n", - "TX total 2012 26060796.0 Texas 268601.0 97.0\n", - "WA total 2012 6895318.0 Washington 71303.0 96.7\n", - "AL total 2012 4817528.0 Alabama 52423.0 91.9\n", - "LA total 2012 4602134.0 Louisiana 51843.0 88.8\n", - "WI total 2012 5724554.0 Wisconsin 65503.0 87.4\n", - "MO total 2012 6024522.0 Missouri 69709.0 86.4\n", - "USA total 2012 313873685.0 United State 3790399.0 82.8\n", - "WV total 2012 1856680.0 West Virginia 24231.0 76.6\n", - "VT total 2012 625953.0 Vermont 9615.0 65.1\n", - "MN total 2012 5379646.0 Minnesota 86943.0 61.9\n", - "MS total 2012 2986450.0 Mississippi 48434.0 61.7\n", - "AZ total 2012 6551149.0 Arizona 114006.0 57.5\n", - "AR total 2012 2949828.0 Arkansas 53182.0 55.5\n", - "OK total 2012 3815780.0 Oklahoma 69903.0 54.6\n", - "IA total 2012 3075039.0 Iowa 56276.0 54.6\n", - "CO total 2012 5189458.0 Colorado 104100.0 49.9\n", - "OR total 2012 3899801.0 Oregon 98386.0 39.6\n", - "ME total 2012 1328501.0 Maine 35387.0 37.5\n", - "KS total 2012 2885398.0 Kansas 82282.0 35.1\n", - "UT total 2012 2854871.0 Utah 84904.0 33.6\n", - "NV total 2012 2754354.0 Nevada 110567.0 24.9\n", - "NE total 2012 1855350.0 Nebraska 77358.0 24.0\n", - "ID total 2012 1595590.0 Idaho 83574.0 19.1\n", - "NM total 2012 2083540.0 New Mexico 121593.0 17.1\n", - "SD total 2012 834047.0 South Dakota 77121.0 10.8\n", - "ND total 2012 701345.0 North Dakota 70704.0 9.9\n", - "MT total 2012 1005494.0 Montana 147046.0 6.8\n", - "WY total 2012 576626.0 Wyoming 97818.0 5.9\n", - "AK total 2012 730307.0 Alaska 656425.0 1.1" - ] - }, - "execution_count": 81, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "pop5.sort_values(by='pop_density',ascending=False)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.6.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/Day76-90/code/cancer_predict.npy b/Day76-90/code/cancer_predict.npy deleted file mode 100644 index a6bf034..0000000 Binary files a/Day76-90/code/cancer_predict.npy and /dev/null differ diff --git a/Day76-90/code/cancer_true.npy b/Day76-90/code/cancer_true.npy deleted file mode 100644 index 97e4b66..0000000 Binary files a/Day76-90/code/cancer_true.npy and /dev/null differ diff --git a/Day76-90/code/state-abbrevs.csv b/Day76-90/code/state-abbrevs.csv deleted file mode 100644 index 6d4db36..0000000 --- a/Day76-90/code/state-abbrevs.csv +++ /dev/null @@ -1,52 +0,0 @@ -"state","abbreviation" -"Alabama","AL" -"Alaska","AK" -"Arizona","AZ" -"Arkansas","AR" -"California","CA" -"Colorado","CO" -"Connecticut","CT" -"Delaware","DE" -"District of Columbia","DC" -"Florida","FL" -"Georgia","GA" -"Hawaii","HI" -"Idaho","ID" -"Illinois","IL" -"Indiana","IN" -"Iowa","IA" -"Kansas","KS" -"Kentucky","KY" -"Louisiana","LA" -"Maine","ME" -"Montana","MT" -"Nebraska","NE" -"Nevada","NV" -"New Hampshire","NH" -"New Jersey","NJ" -"New Mexico","NM" -"New York","NY" -"North Carolina","NC" -"North Dakota","ND" -"Ohio","OH" -"Oklahoma","OK" -"Oregon","OR" -"Maryland","MD" -"Massachusetts","MA" -"Michigan","MI" -"Minnesota","MN" -"Mississippi","MS" -"Missouri","MO" -"Pennsylvania","PA" -"Rhode Island","RI" -"South Carolina","SC" -"South Dakota","SD" -"Tennessee","TN" -"Texas","TX" -"Utah","UT" -"Vermont","VT" -"Virginia","VA" -"Washington","WA" -"West Virginia","WV" -"Wisconsin","WI" -"Wyoming","WY" \ No newline at end of file diff --git a/Day76-90/code/state-areas.csv b/Day76-90/code/state-areas.csv deleted file mode 100644 index 322345c..0000000 --- a/Day76-90/code/state-areas.csv +++ /dev/null @@ -1,53 +0,0 @@ -state,area (sq. mi) -Alabama,52423 -Alaska,656425 -Arizona,114006 -Arkansas,53182 -California,163707 -Colorado,104100 -Connecticut,5544 -Delaware,1954 -Florida,65758 -Georgia,59441 -Hawaii,10932 -Idaho,83574 -Illinois,57918 -Indiana,36420 -Iowa,56276 -Kansas,82282 -Kentucky,40411 -Louisiana,51843 -Maine,35387 -Maryland,12407 -Massachusetts,10555 -Michigan,96810 -Minnesota,86943 -Mississippi,48434 -Missouri,69709 -Montana,147046 -Nebraska,77358 -Nevada,110567 -New Hampshire,9351 -New Jersey,8722 -New Mexico,121593 -New York,54475 -North Carolina,53821 -North Dakota,70704 -Ohio,44828 -Oklahoma,69903 -Oregon,98386 -Pennsylvania,46058 -Rhode Island,1545 -South Carolina,32007 -South Dakota,77121 -Tennessee,42146 -Texas,268601 -Utah,84904 -Vermont,9615 -Virginia,42769 -Washington,71303 -West Virginia,24231 -Wisconsin,65503 -Wyoming,97818 -District of Columbia,68 -Puerto Rico,3515 diff --git a/Day76-90/code/state-population.csv b/Day76-90/code/state-population.csv deleted file mode 100644 index c76110e..0000000 --- a/Day76-90/code/state-population.csv +++ /dev/null @@ -1,2545 +0,0 @@ -state/region,ages,year,population -AL,under18,2012,1117489 -AL,total,2012,4817528 -AL,under18,2010,1130966 -AL,total,2010,4785570 -AL,under18,2011,1125763 -AL,total,2011,4801627 -AL,total,2009,4757938 -AL,under18,2009,1134192 -AL,under18,2013,1111481 -AL,total,2013,4833722 -AL,total,2007,4672840 -AL,under18,2007,1132296 -AL,total,2008,4718206 -AL,under18,2008,1134927 -AL,total,2005,4569805 -AL,under18,2005,1117229 -AL,total,2006,4628981 -AL,under18,2006,1126798 -AL,total,2004,4530729 -AL,under18,2004,1113662 -AL,total,2003,4503491 -AL,under18,2003,1113083 -AL,total,2001,4467634 -AL,under18,2001,1120409 -AL,total,2002,4480089 -AL,under18,2002,1116590 -AL,under18,1999,1121287 -AL,total,1999,4430141 -AL,total,2000,4452173 -AL,under18,2000,1122273 -AL,total,1998,4404701 -AL,under18,1998,1118252 -AL,under18,1997,1122893 -AL,total,1997,4367935 -AL,total,1996,4331103 -AL,total,1995,4296800 -AL,under18,1995,1110553 -AL,under18,1996,1112092 -AL,total,1994,4260229 -AL,total,1993,4214202 -AL,under18,1993,1085606 -AL,under18,1994,1097180 -AL,under18,1992,1072873 -AL,total,1992,4154014 -AL,total,1991,4099156 -AL,under18,1991,1060794 -AL,under18,1990,1050041 -AL,total,1990,4050055 -AK,total,1990,553290 -AK,under18,1990,177502 -AK,total,1992,588736 -AK,under18,1991,182180 -AK,under18,1992,184878 -AK,total,1994,603308 -AK,under18,1994,187439 -AK,total,1991,570193 -AK,total,1993,599434 -AK,under18,1993,187190 -AK,total,1995,604412 -AK,under18,1995,184990 -AK,total,1996,608569 -AK,under18,1996,185360 -AK,under18,1997,188280 -AK,under18,1998,192636 -AK,total,1998,619933 -AK,total,1997,612968 -AK,under18,1999,191422 -AK,total,1999,624779 -AK,total,2000,627963 -AK,under18,2000,190615 -AK,total,2001,633714 -AK,under18,2001,188771 -AK,total,2002,642337 -AK,under18,2002,188482 -AK,total,2003,648414 -AK,under18,2003,186843 -AK,total,2004,659286 -AK,under18,2004,186335 -AK,total,2005,666946 -AK,under18,2005,185304 -AK,total,2006,675302 -AK,under18,2006,185580 -AK,total,2007,680300 -AK,under18,2007,184344 -AK,total,2008,687455 -AK,under18,2008,183124 -AK,under18,2013,188132 -AK,total,2013,735132 -AK,total,2009,698895 -AK,under18,2009,186351 -AK,under18,2010,187902 -AK,total,2010,713868 -AK,under18,2011,188329 -AK,total,2011,723375 -AK,under18,2012,188162 -AK,total,2012,730307 -AZ,under18,2012,1617149 -AZ,total,2012,6551149 -AZ,under18,2011,1616353 -AZ,total,2011,6468796 -AZ,under18,2010,1628563 -AZ,total,2010,6408790 -AZ,under18,2013,1616814 -AZ,total,2013,6626624 -AZ,total,2009,6343154 -AZ,under18,2009,1627343 -AZ,total,2007,6167681 -AZ,under18,2007,1607895 -AZ,total,2008,6280362 -AZ,under18,2008,1628651 -AZ,total,2005,5839077 -AZ,under18,2005,1529168 -AZ,total,2006,6029141 -AZ,under18,2006,1574867 -AZ,total,2004,5652404 -AZ,under18,2004,1484454 -AZ,total,2003,5510364 -AZ,under18,2003,1453671 -AZ,total,2001,5273477 -AZ,under18,2001,1399015 -AZ,total,2002,5396255 -AZ,under18,2002,1427938 -AZ,under18,1999,1332396 -AZ,total,1999,5023823 -AZ,total,2000,5160586 -AZ,under18,2000,1373414 -AZ,total,1998,4883342 -AZ,under18,1998,1285794 -AZ,total,1997,4736990 -AZ,under18,1997,1237159 -AZ,under18,1996,1215285 -AZ,total,1996,4586940 -AZ,total,1995,4432499 -AZ,under18,1995,1173391 -AZ,total,1993,4065440 -AZ,under18,1993,1094233 -AZ,under18,1994,1119857 -AZ,total,1994,4245089 -AZ,under18,1992,1055572 -AZ,under18,1991,1028285 -AZ,total,1991,3788576 -AZ,total,1992,3915740 -AZ,under18,1990,1006040 -AZ,total,1990,3684097 -AR,under18,1990,620933 -AR,total,1990,2356586 -AR,total,1991,2383144 -AR,under18,1991,626212 -AR,under18,1992,638269 -AR,total,1992,2415984 -AR,under18,1994,653842 -AR,total,1994,2494019 -AR,total,1993,2456303 -AR,under18,1993,643474 -AR,under18,1995,667671 -AR,total,1995,2535399 -AR,under18,1996,677912 -AR,total,1996,2572109 -AR,under18,1998,683637 -AR,total,1997,2601091 -AR,under18,1997,680203 -AR,total,1998,2626289 -AR,total,2000,2678588 -AR,under18,2000,680378 -AR,under18,1999,681940 -AR,total,1999,2651860 -AR,total,2002,2705927 -AR,under18,2002,678798 -AR,total,2001,2691571 -AR,under18,2001,679606 -AR,total,2004,2749686 -AR,under18,2004,683166 -AR,total,2003,2724816 -AR,under18,2003,679579 -AR,total,2006,2821761 -AR,under18,2006,697842 -AR,total,2005,2781097 -AR,under18,2005,689787 -AR,total,2008,2874554 -AR,under18,2008,705725 -AR,total,2007,2848650 -AR,under18,2007,702737 -AR,total,2009,2896843 -AR,under18,2009,707886 -AR,under18,2013,709866 -AR,total,2013,2959373 -AR,under18,2011,710576 -AR,total,2011,2938506 -AR,under18,2010,711947 -AR,total,2010,2922280 -AR,under18,2012,710471 -AR,total,2012,2949828 -CA,under18,2012,9209007 -CA,total,2012,37999878 -CA,under18,2011,9252336 -CA,total,2011,37668681 -CA,under18,2010,9284094 -CA,total,2010,37333601 -CA,under18,2013,9174877 -CA,total,2013,38332521 -CA,total,2009,36961229 -CA,under18,2009,9294501 -CA,total,2007,36250311 -CA,under18,2007,9335620 -CA,total,2008,36604337 -CA,under18,2008,9321621 -CA,total,2005,35827943 -CA,under18,2005,9405565 -CA,total,2006,36021202 -CA,under18,2006,9370884 -CA,total,2003,35253159 -CA,under18,2003,9404594 -CA,total,2004,35574576 -CA,under18,2004,9418497 -CA,total,2001,34479458 -CA,under18,2001,9325466 -CA,total,2002,34871843 -CA,under18,2002,9365142 -CA,under18,1999,9207878 -CA,total,1999,33499204 -CA,total,2000,33987977 -CA,under18,2000,9267089 -CA,under18,1998,9163238 -CA,total,1998,32987675 -CA,under18,1997,9135359 -CA,total,1997,32486010 -CA,under18,1996,9079519 -CA,total,1996,32018834 -CA,total,1995,31696582 -CA,under18,1995,8920578 -CA,total,1993,31274928 -CA,under18,1993,8624810 -CA,under18,1994,8790058 -CA,total,1994,31484435 -CA,total,1991,30470736 -CA,under18,1991,8245605 -CA,under18,1992,8439647 -CA,total,1992,30974659 -CA,under18,1990,7980501 -CA,total,1990,29959515 -CO,total,1990,3307618 -CO,under18,1990,881640 -CO,total,1992,3495939 -CO,under18,1992,925577 -CO,under18,1991,896537 -CO,total,1991,3387119 -CO,total,1994,3724168 -CO,under18,1994,966412 -CO,under18,1993,947806 -CO,total,1993,3613734 -CO,under18,1995,984310 -CO,total,1995,3826653 -CO,total,1996,3919972 -CO,under18,1996,1003946 -CO,under18,1997,1030557 -CO,total,1997,4018293 -CO,total,1998,4116639 -CO,under18,1998,1060066 -CO,total,2000,4326921 -CO,under18,2000,1106676 -CO,total,1999,4226018 -CO,under18,1999,1083938 -CO,total,2002,4490406 -CO,under18,2002,1138273 -CO,total,2001,4425687 -CO,under18,2001,1126647 -CO,total,2004,4575013 -CO,under18,2004,1146369 -CO,total,2003,4528732 -CO,under18,2003,1144597 -CO,total,2006,4720423 -CO,under18,2006,1171832 -CO,total,2005,4631888 -CO,under18,2005,1156399 -CO,total,2008,4889730 -CO,under18,2008,1203289 -CO,total,2007,4803868 -CO,under18,2007,1189434 -CO,total,2009,4972195 -CO,under18,2009,1217213 -CO,under18,2013,1237932 -CO,total,2013,5268367 -CO,under18,2010,1226619 -CO,total,2010,5048196 -CO,under18,2011,1230178 -CO,total,2011,5118400 -CO,under18,2012,1232864 -CO,total,2012,5189458 -CT,under18,2012,794959 -CT,total,2012,3591765 -CT,under18,2011,805109 -CT,total,2011,3588948 -CT,under18,2010,814187 -CT,total,2010,3579210 -CT,under18,2013,785566 -CT,total,2013,3596080 -CT,total,2009,3561807 -CT,under18,2009,820839 -CT,total,2007,3527270 -CT,under18,2007,833484 -CT,total,2008,3545579 -CT,under18,2008,826626 -CT,total,2005,3506956 -CT,under18,2005,844034 -CT,total,2006,3517460 -CT,under18,2006,839372 -CT,total,2003,3484336 -CT,under18,2003,851115 -CT,total,2004,3496094 -CT,under18,2004,848979 -CT,total,2001,3432835 -CT,under18,2001,845850 -CT,total,2002,3458749 -CT,under18,2002,848877 -CT,total,1999,3386401 -CT,under18,1999,834654 -CT,total,2000,3411777 -CT,under18,2000,842242 -CT,under18,1998,824600 -CT,total,1998,3365352 -CT,total,1997,3349348 -CT,under18,1997,814373 -CT,under18,1996,811855 -CT,total,1996,3336685 -CT,total,1995,3324144 -CT,under18,1995,808623 -CT,total,1993,3309175 -CT,under18,1993,790749 -CT,under18,1994,801231 -CT,total,1994,3316121 -CT,under18,1991,766304 -CT,total,1991,3302895 -CT,under18,1992,777264 -CT,total,1992,3300712 -CT,total,1990,3291967 -CT,under18,1990,752666 -DE,under18,1990,165628 -DE,total,1990,669567 -DE,under18,1992,174166 -DE,total,1992,694927 -DE,total,1991,683080 -DE,under18,1991,169910 -DE,total,1994,717545 -DE,under18,1994,180833 -DE,total,1993,706378 -DE,under18,1993,176916 -DE,under18,1995,181736 -DE,total,1995,729735 -DE,total,1996,740978 -DE,under18,1996,184021 -DE,under18,1997,186607 -DE,total,1997,751487 -DE,total,1998,763335 -DE,under18,1998,189302 -DE,total,2000,786373 -DE,under18,2000,194914 -DE,total,1999,774990 -DE,under18,1999,192510 -DE,total,2002,806169 -DE,under18,2002,196946 -DE,total,2001,795699 -DE,under18,2001,196038 -DE,total,2004,830803 -DE,under18,2004,199631 -DE,total,2003,818003 -DE,under18,2003,198045 -DE,total,2006,859268 -DE,under18,2006,203729 -DE,total,2005,845150 -DE,under18,2005,201988 -DE,total,2008,883874 -DE,under18,2008,206116 -DE,total,2007,871749 -DE,under18,2007,205155 -DE,under18,2013,203558 -DE,total,2013,925749 -DE,total,2009,891730 -DE,under18,2009,206213 -DE,under18,2010,205478 -DE,total,2010,899711 -DE,under18,2011,204801 -DE,total,2011,907985 -DE,under18,2012,204586 -DE,total,2012,917053 -DC,under18,2012,107642 -DC,total,2012,633427 -DC,under18,2011,103906 -DC,total,2011,619624 -DC,under18,2010,101309 -DC,total,2010,605125 -DC,under18,2013,111474 -DC,total,2013,646449 -DC,total,2009,592228 -DC,under18,2009,102098 -DC,total,2007,574404 -DC,under18,2007,104126 -DC,total,2008,580236 -DC,under18,2008,102257 -DC,total,2005,567136 -DC,under18,2005,107187 -DC,total,2006,570681 -DC,under18,2006,105651 -DC,total,2003,568502 -DC,under18,2003,111403 -DC,total,2004,567754 -DC,under18,2004,109756 -DC,total,2001,574504 -DC,under18,2001,114625 -DC,total,2002,573158 -DC,under18,2002,113822 -DC,total,1999,570220 -DC,under18,1999,115003 -DC,total,2000,572046 -DC,under18,2000,114503 -DC,under18,1998,113839 -DC,total,1998,565232 -DC,under18,1997,119531 -DC,total,1997,567739 -DC,under18,1996,121210 -DC,total,1996,572379 -DC,total,1995,580519 -DC,under18,1995,123620 -DC,total,1993,595302 -DC,under18,1993,120471 -DC,under18,1994,122170 -DC,total,1994,589240 -DC,total,1991,600870 -DC,under18,1991,116825 -DC,under18,1992,118636 -DC,total,1992,597567 -DC,under18,1990,112632 -DC,total,1990,605321 -FL,total,1990,13033307 -FL,under18,1990,2988807 -FL,under18,1991,3045638 -FL,total,1991,13369798 -FL,total,1994,14239444 -FL,under18,1994,3299887 -FL,under18,1993,3214066 -FL,total,1993,13927185 -FL,total,1992,13650553 -FL,under18,1992,3120439 -FL,under18,1995,3366468 -FL,total,1995,14537875 -FL,total,1996,14853360 -FL,under18,1996,3431695 -FL,under18,1998,3557561 -FL,under18,1997,3502269 -FL,total,1997,15186304 -FL,total,1998,15486559 -FL,total,1999,15759421 -FL,under18,1999,3611711 -FL,total,2000,16047515 -FL,under18,2000,3654880 -FL,total,2001,16356966 -FL,under18,2001,3714439 -FL,total,2002,16689370 -FL,under18,2002,3774624 -FL,total,2003,17004085 -FL,under18,2003,3820876 -FL,total,2004,17415318 -FL,under18,2004,3890734 -FL,total,2005,17842038 -FL,under18,2005,3968178 -FL,total,2006,18166990 -FL,under18,2006,4022912 -FL,total,2007,18367842 -FL,under18,2007,4031098 -FL,total,2008,18527305 -FL,under18,2008,4018372 -FL,total,2009,18652644 -FL,under18,2009,3997283 -FL,under18,2013,4026674 -FL,total,2013,19552860 -FL,under18,2010,3999532 -FL,total,2010,18846054 -FL,under18,2011,4002550 -FL,total,2011,19083482 -FL,under18,2012,4012421 -FL,total,2012,19320749 -GA,total,2012,9915646 -GA,under18,2012,2487831 -GA,under18,2011,2488898 -GA,total,2011,9810181 -GA,under18,2010,2490884 -GA,total,2010,9713248 -GA,total,2013,9992167 -GA,total,2009,9620846 -GA,under18,2009,2485781 -GA,under18,2013,2489709 -GA,total,2007,9349988 -GA,under18,2007,2456249 -GA,total,2008,9504843 -GA,under18,2008,2479097 -GA,total,2005,8925922 -GA,under18,2005,2353604 -GA,total,2006,9155813 -GA,under18,2006,2406014 -GA,total,2003,8622793 -GA,under18,2003,2278710 -GA,total,2004,8769252 -GA,under18,2004,2308855 -GA,total,2001,8377038 -GA,under18,2001,2215390 -GA,total,2002,8508256 -GA,under18,2002,2249784 -GA,total,1999,8045965 -GA,under18,1999,2130698 -GA,total,2000,8227303 -GA,under18,2000,2176576 -GA,total,1997,7685099 -GA,under18,1997,2034163 -GA,under18,1998,2078998 -GA,total,1998,7863536 -GA,under18,1996,1993171 -GA,total,1996,7501069 -GA,total,1995,7328413 -GA,under18,1995,1949818 -GA,under18,1992,1817781 -GA,total,1992,6817203 -GA,total,1993,6978240 -GA,under18,1993,1865021 -GA,under18,1994,1906539 -GA,total,1994,7157165 -GA,total,1991,6653005 -GA,under18,1991,1773675 -GA,under18,1990,1747363 -GA,total,1990,6512602 -HI,under18,1990,279983 -HI,total,1990,1113491 -HI,total,1991,1136754 -HI,under18,1991,287871 -HI,under18,1994,307517 -HI,total,1994,1187536 -HI,total,1993,1172838 -HI,under18,1993,301473 -HI,under18,1992,295124 -HI,total,1992,1158613 -HI,total,1995,1196854 -HI,under18,1995,310325 -HI,under18,1996,311213 -HI,total,1996,1203755 -HI,under18,1998,304576 -HI,total,1998,1215233 -HI,total,1997,1211640 -HI,under18,1997,309465 -HI,total,2000,1213519 -HI,under18,2000,295352 -HI,total,1999,1210300 -HI,under18,1999,299680 -HI,total,2002,1239613 -HI,under18,2002,293600 -HI,total,2001,1225948 -HI,under18,2001,294133 -HI,total,2004,1273569 -HI,under18,2004,298103 -HI,total,2003,1251154 -HI,under18,2003,294519 -HI,total,2006,1309731 -HI,under18,2006,299313 -HI,total,2005,1292729 -HI,under18,2005,298497 -HI,total,2008,1332213 -HI,under18,2008,301094 -HI,total,2007,1315675 -HI,under18,2007,300207 -HI,under18,2013,307266 -HI,total,2009,1346717 -HI,under18,2009,302796 -HI,total,2013,1404054 -HI,total,2010,1363731 -HI,under18,2010,303812 -HI,total,2011,1376897 -HI,under18,2011,305396 -HI,under18,2012,305981 -HI,total,2012,1390090 -ID,total,2012,1595590 -ID,under18,2012,427177 -ID,under18,2011,428535 -ID,total,2011,1583930 -ID,under18,2010,428961 -ID,total,2010,1570718 -ID,total,2013,1612136 -ID,total,2009,1554439 -ID,under18,2009,426076 -ID,under18,2013,427781 -ID,total,2007,1505105 -ID,under18,2007,415024 -ID,total,2008,1534320 -ID,under18,2008,422347 -ID,total,2005,1428241 -ID,under18,2005,394651 -ID,total,2006,1468669 -ID,under18,2006,404753 -ID,total,2003,1363380 -ID,under18,2003,379241 -ID,total,2004,1391802 -ID,under18,2004,384692 -ID,total,2001,1319962 -ID,under18,2001,373145 -ID,total,2002,1340372 -ID,under18,2002,375986 -ID,total,1999,1275674 -ID,under18,1999,366689 -ID,total,2000,1299430 -ID,under18,2000,370430 -ID,total,1997,1228520 -ID,under18,1997,357779 -ID,under18,1998,362189 -ID,total,1998,1252330 -ID,under18,1996,353824 -ID,total,1996,1203083 -ID,total,1995,1177322 -ID,under18,1995,349248 -ID,under18,1992,324972 -ID,total,1992,1071685 -ID,total,1993,1108768 -ID,under18,1993,333838 -ID,under18,1994,344242 -ID,total,1994,1145140 -ID,total,1991,1041316 -ID,under18,1991,316732 -ID,under18,1990,313373 -ID,total,1990,1012384 -IL,under18,1990,2940837 -IL,total,1990,11453316 -IL,total,1991,11568964 -IL,under18,1991,2988715 -IL,under18,1994,3110938 -IL,total,1994,11912585 -IL,total,1993,11809579 -IL,under18,1993,3066541 -IL,under18,1992,3033427 -IL,total,1992,11694184 -IL,total,1995,12008437 -IL,under18,1995,3152984 -IL,under18,1996,3192916 -IL,total,1996,12101997 -IL,under18,1998,3225252 -IL,total,1998,12271847 -IL,total,1997,12185715 -IL,under18,1997,3222114 -IL,total,2000,12434161 -IL,under18,2000,3244944 -IL,total,1999,12359020 -IL,under18,1999,3240034 -IL,total,2002,12525556 -IL,under18,2002,3238362 -IL,total,2001,12488445 -IL,under18,2001,3243617 -IL,total,2004,12589773 -IL,under18,2004,3211599 -IL,total,2003,12556006 -IL,under18,2003,3225547 -IL,total,2006,12643955 -IL,under18,2006,3181246 -IL,total,2005,12609903 -IL,under18,2005,3197318 -IL,total,2008,12747038 -IL,under18,2008,3153401 -IL,total,2007,12695866 -IL,under18,2007,3170134 -IL,under18,2013,3023307 -IL,total,2009,12796778 -IL,under18,2009,3138406 -IL,total,2013,12882135 -IL,total,2010,12839695 -IL,under18,2010,3122092 -IL,total,2011,12855970 -IL,under18,2011,3089833 -IL,under18,2012,3057042 -IL,total,2012,12868192 -IN,total,2012,6537782 -IN,under18,2012,1589655 -IN,under18,2011,1598091 -IN,total,2011,6516336 -IN,under18,2010,1605883 -IN,total,2010,6489965 -IN,total,2013,6570902 -IN,total,2009,6459325 -IN,under18,2009,1609704 -IN,under18,2013,1586027 -IN,total,2007,6379599 -IN,under18,2007,1609494 -IN,total,2008,6424806 -IN,under18,2008,1611494 -IN,total,2005,6278616 -IN,under18,2005,1593898 -IN,total,2006,6332669 -IN,under18,2006,1603107 -IN,total,2003,6196638 -IN,under18,2003,1582560 -IN,total,2004,6233007 -IN,under18,2004,1586281 -IN,total,2001,6127760 -IN,under18,2001,1579527 -IN,total,2002,6155967 -IN,under18,2002,1580814 -IN,total,1999,6044970 -IN,under18,1999,1566079 -IN,total,2000,6091866 -IN,under18,2000,1574989 -IN,total,1997,5955267 -IN,under18,1997,1539270 -IN,under18,1998,1551960 -IN,total,1998,5998881 -IN,under18,1996,1517961 -IN,total,1996,5906013 -IN,total,1995,5851459 -IN,under18,1995,1507916 -IN,under18,1992,1461650 -IN,total,1992,5674547 -IN,total,1993,5739019 -IN,under18,1993,1473007 -IN,under18,1994,1491802 -IN,total,1994,5793526 -IN,total,1991,5616388 -IN,under18,1991,1450759 -IN,under18,1990,1437209 -IN,total,1990,5557798 -IA,under18,1990,719366 -IA,total,1990,2781018 -IA,total,1991,2797613 -IA,under18,1991,724446 -IA,under18,1994,728397 -IA,total,1994,2850746 -IA,total,1993,2836972 -IA,under18,1993,727751 -IA,under18,1992,724798 -IA,total,1992,2818401 -IA,total,1995,2867373 -IA,under18,1995,726961 -IA,under18,1996,729177 -IA,total,1996,2880001 -IA,under18,1998,729943 -IA,total,1998,2902872 -IA,total,1997,2891119 -IA,under18,1997,729806 -IA,total,2000,2929067 -IA,under18,2000,733337 -IA,total,1999,2917634 -IA,under18,1999,732671 -IA,total,2002,2934234 -IA,under18,2002,723685 -IA,total,2001,2931997 -IA,under18,2001,728601 -IA,total,2004,2953635 -IA,under18,2004,718708 -IA,total,2003,2941999 -IA,under18,2003,720102 -IA,total,2006,2982644 -IA,under18,2006,721703 -IA,total,2005,2964454 -IA,under18,2005,718488 -IA,total,2008,3016734 -IA,under18,2008,725658 -IA,total,2007,2999212 -IA,under18,2007,723632 -IA,under18,2013,724032 -IA,total,2009,3032870 -IA,under18,2009,726969 -IA,total,2013,3090416 -IA,total,2010,3050314 -IA,under18,2010,727717 -IA,total,2011,3064102 -IA,under18,2011,725522 -IA,under18,2012,723917 -IA,total,2012,3075039 -KS,total,2012,2885398 -KS,under18,2012,726668 -KS,under18,2011,726787 -KS,total,2011,2869548 -KS,under18,2010,727729 -KS,total,2010,2858910 -KS,total,2013,2893957 -KS,total,2009,2832704 -KS,under18,2009,721841 -KS,under18,2013,724092 -KS,total,2007,2783785 -KS,under18,2007,711005 -KS,total,2008,2808076 -KS,under18,2008,714689 -KS,total,2005,2745299 -KS,under18,2005,704689 -KS,total,2006,2762931 -KS,under18,2006,705277 -KS,total,2003,2723004 -KS,under18,2003,707847 -KS,total,2004,2734373 -KS,under18,2004,705456 -KS,total,2001,2702162 -KS,under18,2001,710923 -KS,total,2002,2713535 -KS,under18,2002,709416 -KS,total,1999,2678338 -KS,under18,1999,713022 -KS,total,2000,2693681 -KS,under18,2000,713887 -KS,total,1997,2635292 -KS,under18,1997,704001 -KS,under18,1998,710402 -KS,total,1998,2660598 -KS,under18,1996,696298 -KS,total,1996,2614554 -KS,total,1995,2601008 -KS,under18,1995,694124 -KS,under18,1992,680871 -KS,total,1992,2532395 -KS,total,1993,2556547 -KS,under18,1993,687262 -KS,under18,1994,693673 -KS,total,1994,2580513 -KS,total,1991,2498722 -KS,under18,1991,672033 -KS,under18,1990,662641 -KS,total,1990,2481349 -KY,under18,1990,945951 -KY,total,1990,3694048 -KY,total,1991,3722328 -KY,under18,1991,951512 -KY,under18,1994,981439 -KY,total,1994,3849088 -KY,total,1993,3812206 -KY,under18,1993,971134 -KY,under18,1992,963861 -KY,total,1992,3765469 -KY,total,1995,3887427 -KY,under18,1995,984486 -KY,under18,1996,987062 -KY,total,1996,3919536 -KY,under18,1998,997296 -KY,total,1998,3985391 -KY,total,1997,3952747 -KY,under18,1997,1002609 -KY,total,2000,4049021 -KY,under18,2000,994984 -KY,total,1999,4018053 -KY,under18,1999,996382 -KY,total,2002,4089875 -KY,under18,2002,995251 -KY,total,2001,4068132 -KY,under18,2001,994105 -KY,total,2004,4146101 -KY,under18,2004,998459 -KY,total,2003,4117170 -KY,under18,2003,998485 -KY,total,2006,4219239 -KY,under18,2006,1011295 -KY,total,2005,4182742 -KY,under18,2005,1004020 -KY,total,2008,4289878 -KY,under18,2008,1022001 -KY,total,2007,4256672 -KY,under18,2007,1016288 -KY,under18,2013,1014004 -KY,total,2009,4317074 -KY,under18,2009,1021710 -KY,total,2013,4395295 -KY,total,2010,4347698 -KY,under18,2010,1023679 -KY,total,2011,4366869 -KY,under18,2011,1021926 -KY,under18,2012,1017350 -KY,total,2012,4379730 -LA,total,2012,4602134 -LA,under18,2012,1114620 -LA,under18,2011,1116579 -LA,total,2011,4575197 -LA,under18,2010,1118576 -LA,total,2010,4545392 -LA,total,2013,4625470 -LA,total,2009,4491648 -LA,under18,2009,1114228 -LA,under18,2013,1112957 -LA,total,2007,4375581 -LA,under18,2007,1096642 -LA,total,2008,4435586 -LA,under18,2008,1108728 -LA,total,2005,4576628 -LA,under18,2005,1177954 -LA,total,2006,4302665 -LA,under18,2006,1078779 -LA,total,2003,4521042 -LA,under18,2003,1188070 -LA,total,2004,4552238 -LA,under18,2004,1182731 -LA,total,2001,4477875 -LA,under18,2001,1204187 -LA,total,2002,4497267 -LA,under18,2002,1194819 -LA,total,2000,4471885 -LA,under18,2000,1217670 -LA,total,1999,4460811 -LA,under18,1999,1227167 -LA,total,1997,4421072 -LA,under18,1997,1239665 -LA,under18,1998,1232984 -LA,total,1998,4440344 -LA,under18,1996,1244627 -LA,total,1996,4398877 -LA,total,1995,4378779 -LA,under18,1995,1250112 -LA,under18,1992,1237034 -LA,total,1992,4293003 -LA,total,1993,4316428 -LA,under18,1993,1239161 -LA,under18,1994,1247631 -LA,total,1994,4347481 -LA,total,1991,4253279 -LA,under18,1991,1222330 -LA,under18,1990,1205984 -LA,total,1990,4221532 -ME,under18,1990,308066 -ME,total,1990,1231719 -ME,total,1991,1237081 -ME,under18,1991,309871 -ME,under18,1994,311570 -ME,total,1994,1242662 -ME,total,1993,1242302 -ME,under18,1993,310966 -ME,under18,1992,310679 -ME,total,1992,1238508 -ME,total,1995,1243481 -ME,under18,1995,309173 -ME,under18,1996,307740 -ME,total,1996,1249060 -ME,under18,1998,304496 -ME,total,1998,1259127 -ME,total,1997,1254774 -ME,under18,1997,305097 -ME,total,1999,1266808 -ME,under18,1999,302321 -ME,total,2000,1277072 -ME,under18,2000,301407 -ME,total,2002,1295960 -ME,under18,2002,298595 -ME,total,2001,1285692 -ME,under18,2001,300088 -ME,total,2004,1313688 -ME,under18,2004,294791 -ME,total,2003,1306513 -ME,under18,2003,296786 -ME,total,2006,1323619 -ME,under18,2006,288945 -ME,total,2005,1318787 -ME,under18,2005,292039 -ME,total,2008,1330509 -ME,under18,2008,282204 -ME,total,2007,1327040 -ME,under18,2007,286185 -ME,under18,2013,261276 -ME,total,2009,1329590 -ME,under18,2009,277946 -ME,total,2013,1328302 -ME,total,2010,1327366 -ME,under18,2010,273061 -ME,total,2011,1327844 -ME,under18,2011,268737 -ME,under18,2012,264846 -ME,total,2012,1328501 -MD,total,2012,5884868 -MD,under18,2012,1346235 -MD,under18,2011,1348766 -MD,total,2011,5840241 -MD,under18,2010,1351983 -MD,total,2010,5787193 -MD,total,2013,5928814 -MD,total,2009,5730388 -MD,under18,2009,1353631 -MD,under18,2013,1344522 -MD,total,2007,5653408 -MD,under18,2007,1369563 -MD,total,2008,5684965 -MD,under18,2008,1359214 -MD,total,2005,5592379 -MD,under18,2005,1382966 -MD,total,2006,5627367 -MD,under18,2006,1377756 -MD,total,2003,5496269 -MD,under18,2003,1379641 -MD,total,2004,5546935 -MD,under18,2004,1383450 -MD,total,2001,5374691 -MD,under18,2001,1366552 -MD,total,2002,5440389 -MD,under18,2002,1375354 -MD,total,2000,5311034 -MD,under18,2000,1356961 -MD,total,1999,5254509 -MD,under18,1999,1348659 -MD,total,1997,5157328 -MD,under18,1997,1321306 -MD,under18,1998,1338727 -MD,total,1998,5204464 -MD,under18,1996,1303816 -MD,total,1996,5111986 -MD,total,1995,5070033 -MD,under18,1995,1300695 -MD,under18,1992,1235498 -MD,total,1992,4923369 -MD,total,1993,4971889 -MD,under18,1993,1261738 -MD,under18,1994,1280772 -MD,total,1994,5023060 -MD,total,1991,4867641 -MD,under18,1991,1208898 -MD,under18,1990,1180426 -MD,total,1990,4799770 -MA,under18,1990,1353806 -MA,total,1990,6022639 -MA,total,1991,6018470 -MA,under18,1991,1375110 -MA,under18,1994,1437069 -MA,total,1994,6095241 -MA,total,1993,6060569 -MA,under18,1993,1415724 -MA,under18,1992,1390188 -MA,total,1992,6028709 -MA,total,1995,6141445 -MA,under18,1995,1453489 -MA,under18,1996,1468614 -MA,total,1996,6179756 -MA,under18,1998,1491652 -MA,total,1998,6271838 -MA,total,1997,6226058 -MA,under18,1997,1478203 -MA,total,1999,6317345 -MA,under18,1999,1495818 -MA,total,2000,6361104 -MA,under18,2000,1501334 -MA,total,2001,6397634 -MA,under18,2001,1505028 -MA,total,2002,6417206 -MA,under18,2002,1502652 -MA,total,2004,6412281 -MA,under18,2004,1479541 -MA,total,2003,6422565 -MA,under18,2003,1493372 -MA,total,2006,6410084 -MA,under18,2006,1450202 -MA,total,2005,6403290 -MA,under18,2005,1464140 -MA,total,2008,6468967 -MA,under18,2008,1429727 -MA,total,2007,6431559 -MA,under18,2007,1439757 -MA,under18,2013,1393946 -MA,total,2009,6517613 -MA,under18,2009,1422935 -MA,total,2013,6692824 -MA,total,2010,6563263 -MA,under18,2010,1415962 -MA,total,2011,6606285 -MA,under18,2011,1407240 -MA,under18,2012,1399417 -MA,total,2012,6645303 -MI,total,2012,9882519 -MI,under18,2012,2269365 -MI,under18,2011,2299116 -MI,total,2011,9874589 -MI,under18,2010,2333121 -MI,total,2010,9876149 -MI,total,2013,9895622 -MI,total,2009,9901591 -MI,under18,2009,2372603 -MI,under18,2013,2245201 -MI,total,2007,10001284 -MI,under18,2007,2470063 -MI,total,2008,9946889 -MI,under18,2008,2418879 -MI,total,2005,10051137 -MI,under18,2005,2531839 -MI,total,2006,10036081 -MI,under18,2006,2503548 -MI,total,2003,10041152 -MI,under18,2003,2569080 -MI,total,2004,10055315 -MI,under18,2004,2553314 -MI,total,2002,10015710 -MI,under18,2002,2584310 -MI,total,2001,9991120 -MI,under18,2001,2593310 -MI,total,2000,9952450 -MI,under18,2000,2596114 -MI,total,1999,9897116 -MI,under18,1999,2591944 -MI,total,1997,9809051 -MI,under18,1997,2582270 -MI,under18,1998,2586343 -MI,total,1998,9847942 -MI,under18,1996,2569745 -MI,total,1996,9758645 -MI,total,1995,9676211 -MI,under18,1995,2556799 -MI,under18,1992,2501765 -MI,total,1992,9479065 -MI,total,1993,9540114 -MI,under18,1993,2522249 -MI,under18,1994,2535196 -MI,total,1994,9597737 -MI,total,1991,9400446 -MI,under18,1991,2484957 -MI,under18,1990,2459633 -MI,total,1990,9311319 -MN,under18,1990,1176680 -MN,total,1990,4389857 -MN,total,1991,4440859 -MN,under18,1991,1191207 -MN,under18,1994,1238949 -MN,total,1994,4610355 -MN,total,1993,4555956 -MN,under18,1993,1226723 -MN,under18,1992,1213068 -MN,total,1992,4495572 -MN,total,1995,4660180 -MN,under18,1995,1245932 -MN,under18,1996,1252722 -MN,total,1996,4712827 -MN,under18,1998,1275940 -MN,total,1998,4813412 -MN,total,1997,4763390 -MN,under18,1997,1264250 -MN,total,1999,4873481 -MN,under18,1999,1283102 -MN,total,2000,4933692 -MN,under18,2000,1289715 -MN,total,2001,4982796 -MN,under18,2001,1291261 -MN,total,2002,5018935 -MN,under18,2002,1288795 -MN,total,2004,5087713 -MN,under18,2004,1281946 -MN,total,2003,5053572 -MN,under18,2003,1283687 -MN,total,2006,5163555 -MN,under18,2006,1282381 -MN,total,2005,5119598 -MN,under18,2005,1280557 -MN,total,2008,5247018 -MN,under18,2008,1284179 -MN,total,2007,5207203 -MN,under18,2007,1285074 -MN,under18,2013,1279111 -MN,total,2009,5281203 -MN,under18,2009,1284103 -MN,total,2013,5420380 -MN,total,2010,5310337 -MN,under18,2010,1282693 -MN,total,2011,5347108 -MN,under18,2011,1280424 -MN,under18,2012,1278050 -MN,total,2012,5379646 -MS,total,2012,2986450 -MS,under18,2012,742941 -MS,under18,2011,747742 -MS,total,2011,2977886 -MS,under18,2010,754111 -MS,total,2010,2970047 -MS,total,2013,2991207 -MS,total,2009,2958774 -MS,under18,2009,758539 -MS,under18,2013,737432 -MS,total,2007,2928350 -MS,under18,2007,761171 -MS,total,2008,2947806 -MS,under18,2008,760572 -MS,total,2005,2905943 -MS,under18,2005,760870 -MS,total,2006,2904978 -MS,under18,2006,756990 -MS,total,2003,2868312 -MS,under18,2003,759447 -MS,total,2004,2889010 -MS,under18,2004,760410 -MS,total,2002,2858681 -MS,under18,2002,763148 -MS,total,2001,2852994 -MS,under18,2001,768418 -MS,total,2000,2848353 -MS,under18,2000,774353 -MS,total,1999,2828408 -MS,under18,1999,775662 -MS,total,1997,2777004 -MS,under18,1997,774832 -MS,under18,1998,773721 -MS,total,1998,2804834 -MS,under18,1996,769680 -MS,total,1996,2748085 -MS,total,1995,2722659 -MS,under18,1995,767892 -MS,under18,1992,750224 -MS,total,1992,2623734 -MS,total,1993,2655100 -MS,under18,1993,755820 -MS,under18,1994,763795 -MS,total,1994,2688992 -MS,total,1991,2598733 -MS,under18,1991,738911 -MS,under18,1990,733660 -MS,total,1990,2578897 -MO,under18,1990,1316423 -MO,total,1990,5128880 -MO,total,1991,5170800 -MO,under18,1991,1332306 -MO,under18,1994,1378700 -MO,total,1994,5324497 -MO,total,1993,5271175 -MO,under18,1993,1365903 -MO,under18,1992,1349729 -MO,total,1992,5217101 -MO,under18,1996,1408732 -MO,total,1996,5431553 -MO,total,1995,5378247 -MO,under18,1995,1393554 -MO,under18,1998,1428999 -MO,total,1998,5521765 -MO,total,1997,5481193 -MO,under18,1997,1419837 -MO,total,1999,5561948 -MO,under18,1999,1428047 -MO,total,2000,5607285 -MO,under18,2000,1428383 -MO,total,2001,5641142 -MO,under18,2001,1426575 -MO,total,2002,5674825 -MO,under18,2002,1424513 -MO,total,2004,5747741 -MO,under18,2004,1420956 -MO,total,2003,5709403 -MO,under18,2003,1421927 -MO,total,2006,5842704 -MO,under18,2006,1428324 -MO,total,2005,5790300 -MO,under18,2005,1422978 -MO,total,2008,5923916 -MO,under18,2008,1428945 -MO,total,2007,5887612 -MO,under18,2007,1431346 -MO,under18,2013,1397685 -MO,total,2009,5961088 -MO,under18,2009,1426603 -MO,total,2013,6044171 -MO,total,2010,5996063 -MO,under18,2010,1424042 -MO,total,2011,6010065 -MO,under18,2011,1414444 -MO,under18,2012,1405015 -MO,total,2012,6024522 -MT,total,2012,1005494 -MT,under18,2012,222905 -MT,under18,2011,222977 -MT,total,2011,997600 -MT,under18,2010,223292 -MT,total,2010,990527 -MT,total,2013,1015165 -MT,total,2009,983982 -MT,under18,2009,223675 -MT,under18,2013,223981 -MT,total,2007,964706 -MT,under18,2007,223135 -MT,total,2008,976415 -MT,under18,2008,223814 -MT,total,2005,940102 -MT,under18,2005,221685 -MT,total,2006,952692 -MT,under18,2006,221930 -MT,total,2003,919630 -MT,under18,2003,223012 -MT,total,2004,930009 -MT,under18,2004,221999 -MT,total,2002,911667 -MT,under18,2002,224772 -MT,total,2001,906961 -MT,under18,2001,227118 -MT,total,1999,897508 -MT,under18,1999,231133 -MT,total,2000,903773 -MT,under18,2000,230067 -MT,total,1997,889865 -MT,under18,1997,232813 -MT,under18,1998,231746 -MT,total,1998,892431 -MT,total,1995,876553 -MT,under18,1995,236583 -MT,under18,1996,235294 -MT,total,1996,886254 -MT,under18,1992,230868 -MT,total,1992,825770 -MT,total,1993,844761 -MT,under18,1993,234987 -MT,under18,1994,237289 -MT,total,1994,861306 -MT,total,1991,809680 -MT,under18,1991,225259 -MT,under18,1990,223677 -MT,total,1990,800204 -NE,under18,1990,430068 -NE,total,1990,1581660 -NE,total,1991,1595919 -NE,under18,1991,434525 -NE,under18,1994,442589 -NE,total,1994,1639041 -NE,total,1993,1625590 -NE,under18,1993,439313 -NE,under18,1992,436378 -NE,total,1992,1611687 -NE,under18,1996,446841 -NE,total,1996,1673740 -NE,total,1995,1656993 -NE,under18,1995,444418 -NE,under18,1998,451192 -NE,total,1998,1695817 -NE,total,1997,1686418 -NE,under18,1997,450076 -NE,total,1999,1704764 -NE,under18,1999,451047 -NE,total,2000,1713820 -NE,under18,2000,450380 -NE,total,2001,1719836 -NE,under18,2001,448307 -NE,total,2002,1728292 -NE,under18,2002,447714 -NE,total,2004,1749370 -NE,under18,2004,448360 -NE,total,2003,1738643 -NE,under18,2003,447444 -NE,total,2006,1772693 -NE,under18,2006,450098 -NE,total,2005,1761497 -NE,under18,2005,448918 -NE,total,2008,1796378 -NE,under18,2008,453787 -NE,total,2007,1783440 -NE,under18,2007,451946 -NE,under18,2013,464348 -NE,total,2009,1812683 -NE,under18,2009,456543 -NE,total,2013,1868516 -NE,total,2010,1829838 -NE,under18,2010,459621 -NE,total,2011,1841749 -NE,under18,2011,460872 -NE,under18,2012,462673 -NE,total,2012,1855350 -NV,total,2012,2754354 -NV,under18,2012,659655 -NV,under18,2011,659236 -NV,total,2011,2717951 -NV,under18,2010,663180 -NV,total,2010,2703230 -NV,total,2013,2790136 -NV,total,2009,2684665 -NV,under18,2009,666041 -NV,under18,2013,661605 -NV,total,2007,2601072 -NV,under18,2007,654053 -NV,total,2008,2653630 -NV,under18,2008,662621 -NV,total,2005,2432143 -NV,under18,2005,611595 -NV,total,2006,2522658 -NV,under18,2006,634403 -NV,total,2003,2248850 -NV,under18,2003,568963 -NV,total,2004,2346222 -NV,under18,2004,591314 -NV,total,2002,2173791 -NV,under18,2002,552816 -NV,total,2001,2098399 -NV,under18,2001,534708 -NV,total,1999,1934718 -NV,under18,1999,493701 -NV,total,2000,2018741 -NV,under18,2000,516018 -NV,total,1997,1764104 -NV,under18,1997,443626 -NV,under18,1998,469424 -NV,total,1998,1853192 -NV,total,1995,1581578 -NV,under18,1995,396223 -NV,under18,1996,419133 -NV,total,1996,1666320 -NV,under18,1992,337396 -NV,total,1992,1351367 -NV,total,1993,1411215 -NV,under18,1993,354990 -NV,under18,1994,376745 -NV,total,1994,1499298 -NV,total,1991,1296172 -NV,under18,1991,325033 -NV,under18,1990,316406 -NV,total,1990,1220695 -NH,under18,1990,277454 -NH,total,1990,1112384 -NH,total,1991,1109929 -NH,under18,1991,281127 -NH,under18,1994,295563 -NH,total,1994,1142561 -NH,total,1993,1129458 -NH,under18,1993,290409 -NH,under18,1992,286314 -NH,total,1992,1117785 -NH,under18,1996,300161 -NH,total,1996,1174719 -NH,total,1995,1157561 -NH,under18,1995,298246 -NH,under18,1998,307292 -NH,total,1998,1205941 -NH,total,1997,1189425 -NH,under18,1997,302834 -NH,total,2000,1239882 -NH,under18,2000,310352 -NH,total,1999,1222015 -NH,under18,1999,308423 -NH,total,2001,1255517 -NH,under18,2001,311877 -NH,total,2002,1269089 -NH,under18,2002,312743 -NH,total,2004,1290121 -NH,under18,2004,309243 -NH,total,2003,1279840 -NH,under18,2003,311412 -NH,total,2005,1298492 -NH,under18,2005,307403 -NH,total,2006,1308389 -NH,under18,2006,305169 -NH,total,2008,1315906 -NH,under18,2008,296029 -NH,total,2007,1312540 -NH,under18,2007,300918 -NH,under18,2013,271122 -NH,total,2009,1316102 -NH,under18,2009,290850 -NH,total,2013,1323459 -NH,total,2010,1316614 -NH,under18,2010,285702 -NH,total,2011,1318075 -NH,under18,2011,280486 -NH,under18,2012,275818 -NH,total,2012,1321617 -NJ,total,2012,8867749 -NJ,under18,2012,2035106 -NJ,under18,2011,2049453 -NJ,total,2011,8836639 -NJ,under18,2010,2062013 -NJ,total,2010,8802707 -NJ,total,2013,8899339 -NJ,total,2009,8755602 -NJ,under18,2009,2068684 -NJ,under18,2013,2022117 -NJ,total,2007,8677885 -NJ,under18,2007,2091023 -NJ,total,2008,8711090 -NJ,under18,2008,2076366 -NJ,total,2006,8661679 -NJ,under18,2006,2106403 -NJ,total,2005,8651974 -NJ,under18,2005,2121878 -NJ,total,2003,8601402 -NJ,under18,2003,2126014 -NJ,total,2004,8634561 -NJ,under18,2004,2129051 -NJ,total,2002,8552643 -NJ,under18,2002,2116591 -NJ,total,2001,8492671 -NJ,under18,2001,2102838 -NJ,total,1999,8359592 -NJ,under18,1999,2066678 -NJ,total,2000,8430621 -NJ,under18,2000,2088885 -NJ,total,1997,8218808 -NJ,under18,1997,2028349 -NJ,under18,1998,2042080 -NJ,total,1998,8287418 -NJ,total,1995,8083242 -NJ,under18,1995,1997187 -NJ,under18,1996,2016502 -NJ,total,1996,8149596 -NJ,under18,1992,1890108 -NJ,total,1992,7880508 -NJ,total,1993,7948915 -NJ,under18,1993,1928623 -NJ,under18,1994,1968232 -NJ,total,1994,8014306 -NJ,total,1991,7814676 -NJ,under18,1991,1849605 -NJ,under18,1990,1818187 -NJ,total,1990,7762963 -NM,total,1990,1521574 -NM,under18,1990,453538 -NM,under18,1991,461811 -NM,total,1991,1555305 -NM,under18,1994,497542 -NM,under18,1993,487742 -NM,total,1993,1636453 -NM,total,1992,1595442 -NM,under18,1992,473176 -NM,total,1994,1682398 -NM,under18,1996,508100 -NM,total,1995,1720394 -NM,under18,1995,504558 -NM,total,1996,1752326 -NM,under18,1998,512801 -NM,total,1998,1793484 -NM,total,1997,1774839 -NM,under18,1997,514500 -NM,under18,1999,511135 -NM,total,1999,1808082 -NM,total,2000,1821204 -NM,under18,2000,508132 -NM,total,2001,1831690 -NM,under18,2001,503404 -NM,total,2002,1855309 -NM,under18,2002,502779 -NM,total,2004,1903808 -NM,under18,2004,501184 -NM,total,2003,1877574 -NM,under18,2003,500777 -NM,total,2005,1932274 -NM,under18,2005,502612 -NM,total,2006,1962137 -NM,under18,2006,505125 -NM,total,2008,2010662 -NM,under18,2008,511214 -NM,total,2007,1990070 -NM,under18,2007,508725 -NM,under18,2013,507540 -NM,total,2013,2085287 -NM,total,2009,2036802 -NM,under18,2009,515470 -NM,total,2010,2064982 -NM,under18,2010,518763 -NM,under18,2011,516513 -NM,total,2011,2077919 -NM,under18,2012,512314 -NM,total,2012,2083540 -NY,total,2012,19576125 -NY,under18,2012,4264694 -NY,total,2011,19502728 -NY,under18,2011,4294555 -NY,under18,2010,4318033 -NY,total,2010,19398228 -NY,total,2009,19307066 -NY,under18,2009,4342926 -NY,total,2013,19651127 -NY,under18,2013,4239976 -NY,total,2007,19132335 -NY,under18,2007,4410949 -NY,total,2008,19212436 -NY,under18,2008,4372170 -NY,total,2006,19104631 -NY,under18,2006,4457777 -NY,total,2005,19132610 -NY,under18,2005,4514456 -NY,total,2003,19175939 -NY,under18,2003,4619506 -NY,total,2004,19171567 -NY,under18,2004,4574065 -NY,total,2002,19137800 -NY,under18,2002,4652232 -NY,total,2001,19082838 -NY,under18,2001,4672425 -NY,under18,1999,4672587 -NY,total,1999,18882725 -NY,total,2000,19001780 -NY,under18,2000,4687374 -NY,under18,1997,4670787 -NY,total,1997,18656546 -NY,total,1998,18755906 -NY,under18,1998,4652140 -NY,total,1996,18588460 -NY,under18,1995,4648419 -NY,total,1995,18524104 -NY,under18,1996,4667647 -NY,total,1994,18459470 -NY,under18,1992,4465539 -NY,total,1992,18246653 -NY,total,1993,18374954 -NY,under18,1993,4538171 -NY,under18,1994,4605284 -NY,total,1991,18122510 -NY,under18,1991,4372727 -NY,under18,1990,4281643 -NY,total,1990,18020784 -NC,under18,1990,1625804 -NC,total,1990,6664016 -NC,total,1991,6784280 -NC,under18,1991,1640394 -NC,total,1993,7042818 -NC,under18,1993,1710267 -NC,under18,1992,1674144 -NC,total,1992,6897214 -NC,under18,1994,1750754 -NC,total,1994,7187398 -NC,total,1995,7344674 -NC,under18,1995,1785150 -NC,under18,1996,1821506 -NC,total,1996,7500670 -NC,under18,1998,1894753 -NC,total,1998,7809122 -NC,total,1997,7656825 -NC,under18,1997,1861621 -NC,total,2000,8081614 -NC,under18,2000,1967626 -NC,total,1999,7949362 -NC,under18,1999,1932141 -NC,total,2001,8210122 -NC,under18,2001,2003782 -NC,total,2002,8326201 -NC,under18,2002,2034451 -NC,total,2004,8553152 -NC,under18,2004,2085165 -NC,total,2003,8422501 -NC,under18,2003,2060838 -NC,total,2005,8705407 -NC,under18,2005,2122485 -NC,total,2006,8917270 -NC,under18,2006,2166393 -NC,total,2008,9309449 -NC,under18,2008,2252101 -NC,total,2007,9118037 -NC,under18,2007,2219168 -NC,under18,2013,2285605 -NC,total,2013,9848060 -NC,total,2009,9449566 -NC,under18,2009,2272955 -NC,total,2010,9559533 -NC,under18,2010,2282288 -NC,under18,2011,2284238 -NC,total,2011,9651377 -NC,under18,2012,2284122 -NC,total,2012,9748364 -ND,total,2012,701345 -ND,under18,2012,156765 -ND,total,2011,684867 -ND,under18,2011,152357 -ND,under18,2010,150179 -ND,total,2010,674344 -ND,total,2009,664968 -ND,under18,2009,148674 -ND,total,2013,723393 -ND,under18,2013,162688 -ND,total,2007,652822 -ND,under18,2007,147263 -ND,total,2008,657569 -ND,under18,2008,147462 -ND,total,2006,649422 -ND,under18,2006,147331 -ND,total,2005,646089 -ND,under18,2005,148119 -ND,total,2003,638817 -ND,under18,2003,150406 -ND,total,2004,644705 -ND,under18,2004,149128 -ND,total,2002,638168 -ND,under18,2002,153097 -ND,total,2001,639062 -ND,under18,2001,156113 -ND,total,1999,644259 -ND,under18,1999,163056 -ND,total,2000,642023 -ND,under18,2000,160477 -ND,total,1997,649716 -ND,under18,1997,167475 -ND,under18,1998,165448 -ND,total,1998,647532 -ND,under18,1996,169257 -ND,total,1996,650382 -ND,total,1995,647832 -ND,under18,1995,171146 -ND,under18,1994,172160 -ND,total,1994,644806 -ND,under18,1992,172052 -ND,total,1992,638223 -ND,total,1993,641216 -ND,under18,1993,172168 -ND,total,1991,635753 -ND,under18,1991,171730 -ND,under18,1990,170920 -ND,total,1990,637685 -OH,under18,1990,2778491 -OH,total,1990,10864162 -OH,total,1991,10945762 -OH,under18,1991,2806959 -OH,total,1993,11101140 -OH,under18,1993,2855785 -OH,under18,1992,2839356 -OH,total,1992,11029431 -OH,under18,1994,2875397 -OH,total,1994,11152455 -OH,total,1995,11202751 -OH,under18,1995,2879930 -OH,under18,1996,2883443 -OH,total,1996,11242827 -OH,under18,1998,2896255 -OH,total,1998,11311536 -OH,total,1997,11277357 -OH,under18,1997,2897375 -OH,total,2000,11363543 -OH,under18,2000,2886585 -OH,total,1999,11335454 -OH,under18,1999,2893270 -OH,total,2001,11387404 -OH,under18,2001,2878123 -OH,total,2002,11407889 -OH,under18,2002,2865674 -OH,total,2004,11452251 -OH,under18,2004,2836068 -OH,total,2003,11434788 -OH,under18,2003,2849573 -OH,total,2005,11463320 -OH,under18,2005,2819794 -OH,total,2006,11481213 -OH,under18,2006,2804828 -OH,total,2008,11515391 -OH,under18,2008,2768968 -OH,total,2007,11500468 -OH,under18,2007,2790347 -OH,under18,2013,2649830 -OH,total,2013,11570808 -OH,total,2009,11528896 -OH,under18,2009,2748051 -OH,total,2010,11545435 -OH,under18,2010,2722589 -OH,under18,2011,2693469 -OH,total,2011,11549772 -OH,under18,2012,2668125 -OH,total,2012,11553031 -OK,total,2012,3815780 -OK,under18,2012,939911 -OK,total,2011,3785534 -OK,under18,2011,935714 -OK,under18,2010,931483 -OK,total,2010,3759263 -OK,total,2009,3717572 -OK,under18,2009,922711 -OK,total,2013,3850568 -OK,under18,2013,947027 -OK,total,2007,3634349 -OK,under18,2007,904328 -OK,total,2008,3668976 -OK,under18,2008,910617 -OK,total,2006,3594090 -OK,under18,2006,894761 -OK,total,2005,3548597 -OK,under18,2005,885316 -OK,total,2003,3504892 -OK,under18,2003,883959 -OK,total,2004,3525233 -OK,under18,2004,881606 -OK,total,2002,3489080 -OK,under18,2002,884961 -OK,total,2001,3467100 -OK,under18,2001,885218 -OK,total,1999,3437148 -OK,under18,1999,895678 -OK,total,2000,3454365 -OK,under18,2000,891847 -OK,total,1997,3372918 -OK,under18,1997,893835 -OK,under18,1998,898501 -OK,total,1998,3405194 -OK,under18,1996,887093 -OK,total,1996,3340129 -OK,total,1995,3308208 -OK,under18,1995,883667 -OK,under18,1994,877803 -OK,total,1994,3280940 -OK,under18,1992,862548 -OK,total,1992,3220517 -OK,total,1993,3252285 -OK,under18,1993,870137 -OK,total,1991,3175440 -OK,under18,1991,849639 -OK,under18,1990,841715 -OK,total,1990,3148825 -OR,under18,1990,742436 -OR,total,1990,2860375 -OR,total,1991,2928507 -OR,under18,1991,752442 -OR,total,1993,3060367 -OR,under18,1993,778973 -OR,under18,1992,770191 -OR,total,1992,2991755 -OR,under18,1994,793435 -OR,total,1994,3121264 -OR,total,1995,3184369 -OR,under18,1995,806512 -OR,under18,1996,816102 -OR,total,1996,3247111 -OR,under18,1998,837928 -OR,total,1998,3352449 -OR,total,1997,3304310 -OR,under18,1997,830002 -OR,total,2000,3429708 -OR,under18,2000,847511 -OR,total,1999,3393941 -OR,under18,1999,843484 -OR,total,2001,3467937 -OR,under18,2001,848663 -OR,total,2002,3513424 -OR,under18,2002,850733 -OR,total,2004,3569463 -OR,under18,2004,846786 -OR,total,2003,3547376 -OR,under18,2003,850251 -OR,total,2005,3613202 -OR,under18,2005,849323 -OR,total,2006,3670883 -OR,under18,2006,857003 -OR,total,2008,3768748 -OR,under18,2008,865664 -OR,total,2007,3722417 -OR,under18,2007,862161 -OR,under18,2013,857606 -OR,total,2013,3930065 -OR,total,2009,3808600 -OR,under18,2009,866194 -OR,total,2010,3837208 -OR,under18,2010,865129 -OR,under18,2011,862518 -OR,total,2011,3867937 -OR,under18,2012,859910 -OR,total,2012,3899801 -PA,total,2012,12764475 -PA,under18,2012,2737905 -PA,total,2011,12741310 -PA,under18,2011,2761343 -PA,under18,2010,2785316 -PA,total,2010,12710472 -PA,total,2009,12666858 -PA,under18,2009,2804929 -PA,total,2013,12773801 -PA,under18,2013,2715645 -PA,total,2007,12563937 -PA,under18,2007,2839574 -PA,total,2008,12612285 -PA,under18,2008,2821004 -PA,total,2006,12510809 -PA,under18,2006,2850778 -PA,total,2005,12449990 -PA,under18,2005,2859793 -PA,total,2003,12374658 -PA,under18,2003,2883270 -PA,total,2004,12410722 -PA,under18,2004,2873125 -PA,total,2002,12331031 -PA,under18,2002,2894935 -PA,total,2001,12298970 -PA,under18,2001,2905836 -PA,total,1999,12263805 -PA,under18,1999,2930193 -PA,total,2000,12284173 -PA,under18,2000,2918850 -PA,total,1997,12227814 -PA,under18,1997,2942240 -PA,under18,1998,2940285 -PA,total,1998,12245672 -PA,under18,1996,2937411 -PA,total,1996,12220464 -PA,total,1995,12198403 -PA,under18,1995,2941531 -PA,under18,1994,2932851 -PA,total,1994,12166050 -PA,under18,1992,2873013 -PA,total,1992,12049450 -PA,total,1993,12119724 -PA,under18,1993,2907351 -PA,total,1991,11982164 -PA,under18,1991,2830059 -PA,under18,1990,2799168 -PA,total,1990,11903299 -RI,under18,1990,225923 -RI,total,1990,1005995 -RI,total,1991,1010649 -RI,under18,1991,229448 -RI,total,1993,1015113 -RI,under18,1993,237218 -RI,under18,1992,232630 -RI,total,1992,1012581 -RI,under18,1994,239100 -RI,total,1994,1015960 -RI,total,1995,1017002 -RI,under18,1995,240553 -RI,under18,1996,240569 -RI,total,1996,1020893 -RI,under18,1998,241760 -RI,total,1998,1031155 -RI,total,1997,1025353 -RI,under18,1997,242079 -RI,total,2000,1050268 -RI,under18,2000,248065 -RI,total,1999,1040402 -RI,under18,1999,247014 -RI,total,2001,1057142 -RI,under18,2001,248296 -RI,total,2002,1065995 -RI,under18,2002,248690 -RI,total,2004,1074579 -RI,under18,2004,246228 -RI,total,2003,1071342 -RI,under18,2003,248075 -RI,total,2005,1067916 -RI,under18,2005,241932 -RI,total,2006,1063096 -RI,under18,2006,237348 -RI,total,2008,1055003 -RI,under18,2008,229798 -RI,total,2007,1057315 -RI,under18,2007,233655 -RI,under18,2013,213987 -RI,total,2013,1051511 -RI,total,2009,1053646 -RI,under18,2009,225902 -RI,total,2010,1052669 -RI,under18,2010,223088 -RI,under18,2011,219783 -RI,total,2011,1050350 -RI,under18,2012,216591 -RI,total,2012,1050304 -SC,total,2012,4723417 -SC,under18,2012,1077455 -SC,total,2011,4673509 -SC,under18,2011,1076524 -SC,under18,2010,1079978 -SC,total,2010,4636361 -SC,total,2009,4589872 -SC,under18,2009,1079729 -SC,total,2013,4774839 -SC,under18,2013,1079798 -SC,total,2007,4444110 -SC,under18,2007,1064190 -SC,total,2008,4528996 -SC,under18,2008,1074116 -SC,total,2006,4357847 -SC,under18,2006,1050042 -SC,total,2005,4270150 -SC,under18,2005,1036941 -SC,total,2003,4150297 -SC,under18,2003,1023785 -SC,total,2004,4210921 -SC,under18,2004,1029111 -SC,total,2002,4107795 -SC,under18,2002,1020531 -SC,total,2001,4064995 -SC,under18,2001,1016134 -SC,total,1999,3974682 -SC,under18,1999,1007050 -SC,total,2000,4024223 -SC,under18,2000,1010641 -SC,total,1997,3859696 -SC,under18,1997,1001681 -SC,under18,1998,1006371 -SC,total,1998,3919235 -SC,under18,1996,987576 -SC,total,1996,3796200 -SC,total,1995,3748582 -SC,under18,1995,975884 -SC,under18,1994,969766 -SC,total,1994,3705397 -SC,under18,1992,947868 -SC,total,1992,3620464 -SC,total,1993,3663314 -SC,under18,1993,956951 -SC,total,1991,3570404 -SC,under18,1991,936122 -SC,under18,1990,921041 -SC,total,1990,3501155 -SD,under18,1990,199453 -SD,total,1990,697101 -SD,total,1991,703669 -SD,under18,1991,201749 -SD,total,1993,722160 -SD,under18,1993,207975 -SD,under18,1992,206632 -SD,total,1992,712801 -SD,under18,1994,208443 -SD,total,1994,730790 -SD,total,1995,737926 -SD,under18,1995,207890 -SD,under18,1996,205780 -SD,total,1996,742214 -SD,under18,1998,204786 -SD,total,1998,746059 -SD,total,1997,744223 -SD,under18,1997,205978 -SD,total,2000,755844 -SD,under18,2000,202681 -SD,total,1999,750413 -SD,under18,1999,203737 -SD,total,2001,757972 -SD,under18,2001,200795 -SD,total,2002,760020 -SD,under18,2002,198694 -SD,total,2004,770396 -SD,under18,2004,196804 -SD,total,2003,763729 -SD,under18,2003,197326 -SD,total,2005,775493 -SD,under18,2005,196476 -SD,total,2006,783033 -SD,under18,2006,197332 -SD,total,2008,799124 -SD,under18,2008,199848 -SD,total,2007,791623 -SD,under18,2007,198847 -SD,under18,2013,207959 -SD,total,2013,844877 -SD,total,2009,807067 -SD,under18,2009,201204 -SD,total,2010,816211 -SD,under18,2010,203145 -SD,under18,2011,203948 -SD,total,2011,823772 -SD,under18,2012,205298 -SD,total,2012,834047 -TN,total,2012,6454914 -TN,under18,2012,1492689 -TN,total,2011,6398361 -TN,under18,2011,1491837 -TN,under18,2010,1495090 -TN,total,2010,6356683 -TN,total,2009,6306019 -TN,under18,2009,1494687 -TN,total,2013,6495978 -TN,under18,2013,1491577 -TN,total,2007,6175727 -TN,under18,2007,1482747 -TN,total,2008,6247411 -TN,under18,2008,1494354 -TN,total,2006,6088766 -TN,under18,2006,1470166 -TN,total,2005,5991057 -TN,under18,2005,1449326 -TN,total,2003,5847812 -TN,under18,2003,1424861 -TN,total,2004,5910809 -TN,under18,2004,1433343 -TN,total,2002,5795918 -TN,under18,2002,1414857 -TN,total,2001,5750789 -TN,under18,2001,1407578 -TN,total,1999,5638706 -TN,under18,1999,1385997 -TN,total,2000,5703719 -TN,under18,2000,1399685 -TN,total,1997,5499233 -TN,under18,1997,1359030 -TN,under18,1998,1369987 -TN,total,1998,5570045 -TN,under18,1996,1345723 -TN,total,1996,5416643 -TN,total,1995,5326936 -TN,under18,1995,1331616 -TN,under18,1994,1310988 -TN,total,1994,5231438 -TN,under18,1992,1259458 -TN,total,1992,5049742 -TN,total,1993,5137584 -TN,under18,1993,1285044 -TN,total,1991,4966587 -TN,under18,1991,1233260 -TN,under18,1990,1220200 -TN,total,1990,4894492 -TX,under18,1990,4906220 -TX,total,1990,17056755 -TX,total,1991,17398005 -TX,under18,1991,5000793 -TX,total,1993,18161612 -TX,under18,1993,5217899 -TX,under18,1992,5109805 -TX,total,1992,17759738 -TX,under18,1994,5331524 -TX,total,1994,18564062 -TX,total,1995,18958751 -TX,under18,1995,5421784 -TX,under18,1996,5551447 -TX,total,1996,19340342 -TX,under18,1998,5759054 -TX,total,1998,20157531 -TX,total,1997,19740317 -TX,under18,1997,5655482 -TX,total,2000,20944499 -TX,under18,2000,5906301 -TX,total,1999,20558220 -TX,under18,1999,5840211 -TX,total,2001,21319622 -TX,under18,2001,5980187 -TX,total,2002,21690325 -TX,under18,2002,6060372 -TX,total,2004,22394023 -TX,under18,2004,6208259 -TX,total,2003,22030931 -TX,under18,2003,6132980 -TX,total,2005,22778123 -TX,under18,2005,6290970 -TX,total,2006,23359580 -TX,under18,2006,6446798 -TX,total,2008,24309039 -TX,under18,2008,6675917 -TX,total,2007,23831983 -TX,under18,2007,6565872 -TX,under18,2013,7041986 -TX,total,2013,26448193 -TX,total,2009,24801761 -TX,under18,2009,6792907 -TX,total,2010,25245178 -TX,under18,2010,6879014 -TX,under18,2011,6931758 -TX,total,2011,25640909 -TX,under18,2012,6985807 -TX,total,2012,26060796 -UT,total,2012,2854871 -UT,under18,2012,888578 -UT,total,2011,2814784 -UT,under18,2011,881350 -UT,under18,2010,873019 -UT,total,2010,2774424 -UT,total,2009,2723421 -UT,under18,2009,857853 -UT,total,2013,2900872 -UT,under18,2013,896589 -UT,total,2007,2597746 -UT,under18,2007,815496 -UT,total,2008,2663029 -UT,under18,2008,837258 -UT,total,2006,2525507 -UT,under18,2006,789957 -UT,total,2005,2457719 -UT,under18,2005,767888 -UT,total,2003,2360137 -UT,under18,2003,740483 -UT,total,2004,2401580 -UT,under18,2004,751771 -UT,total,2002,2324815 -UT,under18,2002,733517 -UT,total,2001,2283715 -UT,under18,2001,726819 -UT,total,1999,2203482 -UT,under18,1999,715398 -UT,total,2000,2244502 -UT,under18,2000,721686 -UT,total,1997,2119784 -UT,under18,1997,699528 -UT,under18,1998,709386 -UT,total,1998,2165961 -UT,under18,1996,687078 -UT,total,1996,2067976 -UT,total,1995,2014179 -UT,under18,1995,679636 -UT,under18,1994,673935 -UT,total,1994,1960446 -UT,under18,1992,648725 -UT,total,1992,1836799 -UT,total,1993,1898404 -UT,under18,1993,662968 -UT,total,1991,1779780 -UT,under18,1991,637216 -UT,under18,1990,627122 -UT,total,1990,1731223 -VT,under18,1990,143296 -VT,total,1990,564798 -VT,total,1991,568606 -VT,under18,1991,145219 -VT,total,1993,577748 -VT,under18,1993,148705 -VT,under18,1992,146983 -VT,total,1992,572751 -VT,under18,1994,150794 -VT,total,1994,583836 -VT,total,1995,589003 -VT,under18,1995,151439 -VT,under18,1996,151490 -VT,total,1996,593701 -VT,under18,1998,148467 -VT,total,1998,600416 -VT,total,1997,597239 -VT,under18,1997,150040 -VT,total,2000,609618 -VT,under18,2000,147549 -VT,total,1999,604683 -VT,under18,1999,147859 -VT,total,2001,612223 -VT,under18,2001,146040 -VT,total,2002,615442 -VT,under18,2002,144441 -VT,total,2004,619920 -VT,under18,2004,141068 -VT,total,2003,617858 -VT,under18,2003,142718 -VT,total,2005,621215 -VT,under18,2005,138933 -VT,total,2006,622892 -VT,under18,2006,136731 -VT,total,2008,624151 -VT,under18,2008,132600 -VT,total,2007,623481 -VT,under18,2007,134695 -VT,under18,2013,122701 -VT,total,2013,626630 -VT,total,2009,624817 -VT,under18,2009,130450 -VT,total,2010,625793 -VT,under18,2010,128601 -VT,under18,2011,126500 -VT,total,2011,626320 -VT,under18,2012,124555 -VT,total,2012,625953 -VA,total,2012,8186628 -VA,under18,2012,1861323 -VA,total,2011,8105850 -VA,under18,2011,1857585 -VA,under18,2010,1855025 -VA,total,2010,8024417 -VA,total,2009,7925937 -VA,under18,2009,1845132 -VA,total,2013,8260405 -VA,under18,2013,1864535 -VA,total,2007,7751000 -VA,under18,2007,1834386 -VA,total,2008,7833496 -VA,under18,2008,1838361 -VA,total,2005,7577105 -VA,under18,2005,1816270 -VA,total,2006,7673725 -VA,under18,2006,1826368 -VA,total,2003,7366977 -VA,under18,2003,1782254 -VA,total,2004,7475575 -VA,under18,2004,1801958 -VA,total,2002,7286873 -VA,under18,2002,1771247 -VA,total,2001,7198362 -VA,under18,2001,1754549 -VA,total,1999,7000174 -VA,under18,1999,1723125 -VA,total,2000,7105817 -VA,under18,2000,1741420 -VA,total,1997,6829183 -VA,under18,1997,1683766 -VA,under18,1998,1706261 -VA,total,1998,6900918 -VA,under18,1996,1664147 -VA,total,1996,6750884 -VA,total,1995,6670693 -VA,under18,1995,1649005 -VA,under18,1994,1628711 -VA,total,1994,6593139 -VA,under18,1992,1581544 -VA,total,1992,6414307 -VA,total,1993,6509630 -VA,under18,1993,1604758 -VA,total,1991,6301217 -VA,under18,1991,1548258 -VA,under18,1990,1520670 -VA,total,1990,6216884 -WA,under18,1990,1301545 -WA,total,1990,4903043 -WA,total,1991,5025624 -WA,under18,1991,1326527 -WA,total,1993,5278842 -WA,under18,1993,1387716 -WA,under18,1992,1365480 -WA,total,1992,5160757 -WA,under18,1994,1409922 -WA,total,1994,5375161 -WA,total,1995,5481027 -WA,under18,1995,1429397 -WA,under18,1996,1449613 -WA,total,1996,5569753 -WA,under18,1998,1494784 -WA,total,1998,5769562 -WA,total,1997,5674747 -WA,under18,1997,1473646 -WA,total,2000,5910512 -WA,under18,2000,1516361 -WA,total,1999,5842564 -WA,under18,1999,1507824 -WA,total,2001,5985722 -WA,under18,2001,1517527 -WA,total,2002,6052349 -WA,under18,2002,1517655 -WA,total,2004,6178645 -WA,under18,2004,1520751 -WA,total,2003,6104115 -WA,under18,2003,1514877 -WA,total,2005,6257305 -WA,under18,2005,1523890 -WA,total,2006,6370753 -WA,under18,2006,1536926 -WA,total,2008,6562231 -WA,under18,2008,1560302 -WA,total,2007,6461587 -WA,under18,2007,1549582 -WA,under18,2013,1595795 -WA,total,2013,6971406 -WA,total,2009,6667426 -WA,under18,2009,1574403 -WA,total,2010,6742256 -WA,under18,2010,1581436 -WA,under18,2011,1584709 -WA,total,2011,6821481 -WA,under18,2012,1588451 -WA,total,2012,6895318 -WV,total,2012,1856680 -WV,under18,2012,384030 -WV,total,2011,1855184 -WV,under18,2011,385283 -WV,under18,2010,387224 -WV,total,2010,1854146 -WV,total,2009,1847775 -WV,under18,2009,389036 -WV,total,2013,1854304 -WV,under18,2013,381678 -WV,total,2007,1834052 -WV,under18,2007,390661 -WV,total,2008,1840310 -WV,under18,2008,390210 -WV,total,2006,1827912 -WV,under18,2006,390637 -WV,total,2005,1820492 -WV,under18,2005,390431 -WV,total,2003,1812295 -WV,under18,2003,392460 -WV,total,2004,1816438 -WV,under18,2004,391856 -WV,total,2002,1805414 -WV,under18,2002,393569 -WV,total,2001,1801481 -WV,under18,2001,395307 -WV,total,1999,1811799 -WV,under18,1999,406784 -WV,total,2000,1807021 -WV,under18,2000,401062 -WV,total,1997,1819113 -WV,under18,1997,418037 -WV,under18,1998,412793 -WV,total,1998,1815609 -WV,under18,1996,422831 -WV,total,1996,1822808 -WV,total,1995,1823700 -WV,under18,1995,428790 -WV,under18,1994,429128 -WV,total,1994,1820421 -WV,under18,1992,433116 -WV,total,1992,1806451 -WV,total,1993,1817539 -WV,under18,1993,432364 -WV,total,1991,1798735 -WV,under18,1991,433918 -WV,under18,1990,436797 -WV,total,1990,1792548 -WI,under18,1990,1302869 -WI,total,1990,4904562 -WI,total,1991,4964343 -WI,under18,1991,1314855 -WI,total,1993,5084889 -WI,under18,1993,1337334 -WI,under18,1992,1330555 -WI,total,1992,5025398 -WI,under18,1994,1348110 -WI,total,1994,5133678 -WI,total,1995,5184836 -WI,under18,1995,1351343 -WI,under18,1996,1352877 -WI,total,1996,5229986 -WI,under18,1998,1362907 -WI,total,1998,5297673 -WI,total,1997,5266213 -WI,under18,1997,1359712 -WI,total,1999,5332666 -WI,under18,1999,1367019 -WI,total,2000,5373999 -WI,under18,2000,1370440 -WI,total,2001,5406835 -WI,under18,2001,1367593 -WI,total,2002,5445162 -WI,under18,2002,1365315 -WI,total,2004,5514026 -WI,under18,2004,1354643 -WI,total,2003,5479203 -WI,under18,2003,1358505 -WI,total,2005,5546166 -WI,under18,2005,1349866 -WI,total,2006,5577655 -WI,under18,2006,1348785 -WI,total,2008,5640996 -WI,under18,2008,1345573 -WI,total,2007,5610775 -WI,under18,2007,1348901 -WI,under18,2013,1307776 -WI,total,2013,5742713 -WI,total,2009,5669264 -WI,under18,2009,1342411 -WI,total,2010,5689060 -WI,under18,2010,1336094 -WI,under18,2011,1325870 -WI,total,2011,5708785 -WI,under18,2012,1316113 -WI,total,2012,5724554 -WY,total,2012,576626 -WY,under18,2012,136526 -WY,total,2011,567329 -WY,under18,2011,135407 -WY,under18,2010,135351 -WY,total,2010,564222 -WY,total,2009,559851 -WY,under18,2009,134960 -WY,total,2013,582658 -WY,under18,2013,137679 -WY,total,2007,534876 -WY,under18,2007,128760 -WY,total,2008,546043 -WY,under18,2008,131511 -WY,total,2006,522667 -WY,under18,2006,125525 -WY,total,2005,514157 -WY,under18,2005,124022 -WY,total,2003,503453 -WY,under18,2003,124182 -WY,total,2004,509106 -WY,under18,2004,123974 -WY,total,2002,500017 -WY,under18,2002,125495 -WY,total,2001,494657 -WY,under18,2001,126212 -WY,total,2000,494300 -WY,under18,2000,128774 -WY,total,1999,491780 -WY,under18,1999,130793 -WY,total,1997,489452 -WY,under18,1997,134328 -WY,under18,1998,132602 -WY,total,1998,490787 -WY,under18,1996,135698 -WY,total,1996,488167 -WY,total,1995,485160 -WY,under18,1995,136785 -WY,under18,1994,137733 -WY,total,1994,480283 -WY,under18,1992,137308 -WY,total,1992,466251 -WY,total,1993,473081 -WY,under18,1993,137458 -WY,total,1991,459260 -WY,under18,1991,136720 -WY,under18,1990,136078 -WY,total,1990,453690 -PR,under18,1990,NaN -PR,total,1990,NaN -PR,total,1991,NaN -PR,under18,1991,NaN -PR,total,1993,NaN -PR,under18,1993,NaN -PR,under18,1992,NaN -PR,total,1992,NaN -PR,under18,1994,NaN -PR,total,1994,NaN -PR,total,1995,NaN -PR,under18,1995,NaN -PR,under18,1996,NaN -PR,total,1996,NaN -PR,under18,1998,NaN -PR,total,1998,NaN -PR,total,1997,NaN -PR,under18,1997,NaN -PR,total,1999,NaN -PR,under18,1999,NaN -PR,total,2000,3810605 -PR,under18,2000,1089063 -PR,total,2001,3818774 -PR,under18,2001,1077566 -PR,total,2002,3823701 -PR,under18,2002,1065051 -PR,total,2004,3826878 -PR,under18,2004,1035919 -PR,total,2003,3826095 -PR,under18,2003,1050615 -PR,total,2005,3821362 -PR,under18,2005,1019447 -PR,total,2006,3805214 -PR,under18,2006,998543 -PR,total,2007,3782995 -PR,under18,2007,973613 -PR,total,2008,3760866 -PR,under18,2008,945705 -PR,under18,2013,814068 -PR,total,2013,3615086 -PR,total,2009,3740410 -PR,under18,2009,920794 -PR,total,2010,3721208 -PR,under18,2010,896945 -PR,under18,2011,869327 -PR,total,2011,3686580 -PR,under18,2012,841740 -PR,total,2012,3651545 -USA,under18,1990,64218512 -USA,total,1990,249622814 -USA,total,1991,252980942 -USA,under18,1991,65313018 -USA,under18,1992,66509177 -USA,total,1992,256514231 -USA,total,1993,259918595 -USA,under18,1993,67594938 -USA,under18,1994,68640936 -USA,total,1994,263125826 -USA,under18,1995,69473140 -USA,under18,1996,70233512 -USA,total,1995,266278403 -USA,total,1996,269394291 -USA,total,1997,272646932 -USA,under18,1997,70920738 -USA,under18,1998,71431406 -USA,total,1998,275854116 -USA,under18,1999,71946051 -USA,total,2000,282162411 -USA,under18,2000,72376189 -USA,total,1999,279040181 -USA,total,2001,284968955 -USA,under18,2001,72671175 -USA,total,2002,287625193 -USA,under18,2002,72936457 -USA,total,2003,290107933 -USA,under18,2003,73100758 -USA,total,2004,292805298 -USA,under18,2004,73297735 -USA,total,2005,295516599 -USA,under18,2005,73523669 -USA,total,2006,298379912 -USA,under18,2006,73757714 -USA,total,2007,301231207 -USA,under18,2007,74019405 -USA,total,2008,304093966 -USA,under18,2008,74104602 -USA,under18,2013,73585872 -USA,total,2013,316128839 -USA,total,2009,306771529 -USA,under18,2009,74134167 -USA,under18,2010,74119556 -USA,total,2010,309326295 -USA,under18,2011,73902222 -USA,total,2011,311582564 -USA,under18,2012,73708179 -USA,total,2012,313873685 diff --git a/Day76-90/res/201205230001213115.png b/Day76-90/res/201205230001213115.png deleted file mode 100644 index 48525f6..0000000 Binary files a/Day76-90/res/201205230001213115.png and /dev/null differ diff --git a/Day76-90/res/201205230001238839.png b/Day76-90/res/201205230001238839.png deleted file mode 100644 index 0d0be92..0000000 Binary files a/Day76-90/res/201205230001238839.png and /dev/null differ diff --git a/Day76-90/res/20120523000125800.png b/Day76-90/res/20120523000125800.png deleted file mode 100644 index 4133386..0000000 Binary files a/Day76-90/res/20120523000125800.png and /dev/null differ diff --git a/Day76-90/res/result-in-jupyter.png b/Day76-90/res/result-in-jupyter.png deleted file mode 100644 index d2c3847..0000000 Binary files a/Day76-90/res/result-in-jupyter.png and /dev/null differ diff --git a/Day76-90/res/result1.png b/Day76-90/res/result1.png deleted file mode 100644 index d455137..0000000 Binary files a/Day76-90/res/result1.png and /dev/null differ diff --git a/Day76-90/res/result2.png b/Day76-90/res/result2.png deleted file mode 100644 index 05140f9..0000000 Binary files a/Day76-90/res/result2.png and /dev/null differ diff --git a/Day76-90/res/result3.png b/Day76-90/res/result3.png deleted file mode 100644 index aa9c81d..0000000 Binary files a/Day76-90/res/result3.png and /dev/null differ diff --git a/Day76-90/res/result4.png b/Day76-90/res/result4.png deleted file mode 100644 index 8081ea0..0000000 Binary files a/Day76-90/res/result4.png and /dev/null differ diff --git a/Day76-90/res/result5.png b/Day76-90/res/result5.png deleted file mode 100644 index 53f0e1d..0000000 Binary files a/Day76-90/res/result5.png and /dev/null differ diff --git a/Day76-90/res/result6.png b/Day76-90/res/result6.png deleted file mode 100644 index 576c80d..0000000 Binary files a/Day76-90/res/result6.png and /dev/null differ diff --git a/Day76-90/res/result7.png b/Day76-90/res/result7.png deleted file mode 100644 index 8f3d9fa..0000000 Binary files a/Day76-90/res/result7.png and /dev/null differ diff --git a/Day76-90/res/result8.png b/Day76-90/res/result8.png deleted file mode 100644 index 44a2d8b..0000000 Binary files a/Day76-90/res/result8.png and /dev/null differ diff --git a/Day76-90/res/result9.png b/Day76-90/res/result9.png deleted file mode 100644 index d9a77c2..0000000 Binary files a/Day76-90/res/result9.png and /dev/null differ diff --git a/Day91-100/100.Python面试题实录.md b/Day91-100/100.Python面试题实录.md new file mode 100644 index 0000000..1421ea8 --- /dev/null +++ b/Day91-100/100.Python面试题实录.md @@ -0,0 +1,4 @@ +## Python面试题实录 + +> **温馨提示**:请访问我的另一个项目[“Python面试宝典”](https://github.com/jackfrued/Python-Interview-Bible)。 + diff --git a/Day91-100/100.Python面试题集.md b/Day91-100/100.Python面试题集.md deleted file mode 100644 index 6916a8a..0000000 --- a/Day91-100/100.Python面试题集.md +++ /dev/null @@ -1,228 +0,0 @@ -## Python面试题 - -1. 说一说Python中的新式类和旧式类有什么区别。 - -2. Python中`is`运算符和`==`运算符有什么区别? - -3. Python中如何动态设置和获取对象属性? - -4. Python如何实现内存管理?有没有可能出现内存泄露的问题? - -5. 阐述列表和集合的底层实现原理。 - -6. 现有字典`d = {'a': 24, 'g': 52, 'i': 12, 'k': 33}`,如何按字典中的值对字典进行排序得到排序后的字典。 - - 答: - - ```Python - - ``` - -7. 实现将字符串`k1:v1|k2:v2|k3:v3`处理成字典`{'k1': 'v1', 'k2': 'v2', 'k3': 'v3'}`。 - - 答: - - ```Python - {key: value for key, value in ( - item.split(':') for item in 'k1:v1|k2:v2|k3:v3'.split('|') - )} - ``` - -8. 写出生成从`m`到`n`公差为`k`的等差数列的生成器。 - - 答: - - ```Python - (value for value in range(m, n + 1, k)) - ``` - - 或 - - ```Python - def generate(m, n, k): - for value in range(m, n + 1, k): - yield value - ``` - - 或 - - ```Python - def generate(m, n, k): - yield from range(m, n + 1, k) - ``` - -9. 请写出你能想到的反转一个字符串的方式。 - - 答: - - ```Python - ''.join(reversed('hello')) - ``` - - 或 - - ```Python - 'hello'[::-1] - ``` - - 或 - - ```Python - def reverse(content): - return ''.join(content[i] for i in range(len(content) - 1, -1, -1)) - - reverse('hello') - ``` - - 或 - - ```Python - def reverse(content): - return reverse(content[1:]) + content[0] if len(content) > 1 else content - - reverse('hello') - ``` - -10. 不使用任何内置函数,将字符串`'123'`转换成整数`123`。 - - 答: - - ```Python - nums = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} - total = 0 - for ch in '123': - total *= 10 - total += nums[ch] - print(total) - ``` - -11. 写一个返回bool值的函数,判断给定的非负整数是不是回文数。 - -12. 用一行代码实现求任意非负整数的阶乘。 - - 答: - - ```Python - from functools import reduce - - (lambda num: reduce(int.__mul__, range(2, num + 1), 1))(5) - ``` - -13. 写一个函数返回传入的整数列表中第二大的元素。 - - 答: - - ```Python - - ``` - -14. 删除列表中的重复元素并保留原有的顺序。 - -15. 找出两个列表中的相同元素和不同元素。 - -16. 列表中的某个元素出现次数占列表元素总数的半数以上,找出这个元素。 - -17. 实现对有序列表进行二分查找的算法。 - -18. 输入年月日,输出这一天是这一年的第几天。 - -19. 统计一个字符串中各个字符出现的次数。 - -20. 在Python中如何实现单例模式? - -21. 下面的代码会输出什么。 - - ```Python - class A: - - def __init__(self, value): - self.__value = value - - @property - def value(self): - return self.__value - - - a = A(1) - a.__value = 2 - print(a.__value) - print(a.value) - ``` - -22. 实现一个记录函数执行时间的装饰器。 - -23. 写一个遍历指定目录下指定后缀名的文件的函数。 - -24. 有如下所示的字典,请将其转换为CSV格式。 - - 转换前: - - ```Python - dict_corp = { - 'cn': {'id': 1, 'name': '土豆', 'desc': '土豆', 'price': {'gold': 20, 'kcoin': 20}}, - 'en': {'id': 1, 'name': 'potato', 'desc': 'potato', 'price': {'gold': 20, 'kcoin': 20}}, - 'kr': {'id': 1, 'name': '감자', 'desc':'감자', 'price': {'gold': 20, 'kcoin': 20}}, - 'jp': {'id': 1, 'name': 'ジャガイモ', 'desc': 'ジャガイモ', 'price': {'gold': 20, 'kcoin': 20}}, - } - ``` - - 转换后: - - ```CSV - ,id,name,desc,gold,kcoin - cn,1,土豆,土豆,20,20 - en,1,potato,potato,20,20 - kr,1,감자,감자,20,20 - jp,1,ジャガイモ,ジャガイモ,20,20 - ``` - -25. 有如下所示的日志文件,请用Python程序或Linux命令打印出独立IP并统计数量。 - - ``` - 221.228.143.52 - - [23/May/2019:08:57:42 +0800] ""GET /about.html HTTP/1.1"" 206 719996 - 218.79.251.215 - - [23/May/2019:08:57:44 +0800] ""GET /index.html HTTP/1.1"" 206 2350253 - 220.178.150.3 - - [23/May/2019:08:57:45 +0800] ""GET /index.html HTTP/1.1"" 200 2350253 - 218.79.251.215 - - [23/May/2019:08:57:52 +0800] ""GET /index.html HTTP/1.1"" 200 2350253 - 219.140.190.130 - - [23/May/2019:08:57:59 +0800] ""GET /index.html HTTP/1.1"" 200 2350253 - 221.228.143.52 - - [23/May/2019:08:58:08 +0800] ""GET /about.html HTTP/1.1"" 206 719996 - 221.228.143.52 - - [23/May/2019:08:58:08 +0800] ""GET /news.html HTTP/1.1"" 206 713242 - 221.228.143.52 - - [23/May/2019:08:58:09 +0800] ""GET /products.html HTTP/1.1"" 206 1200250 - ``` - -26. 请写出从HTML页面源代码中获取a标签href属性的正则表达式。 - - 答: - - ```Python - - ``` - -27. 正则表达式对象的`search`和`match`方法有什么区别? - -28. 当做个线程竞争一个对象且该对象并非线程安全的时候应该怎么办? - -29. 说一下死锁产生的条件以及如何避免死锁的发生。 - -30. 请阐述TCP的优缺点。 - -31. HTTP请求的GET和POST有什么区别? - -32. 说一些你知道的HTTP响应状态码。 - -33. 简单阐述HTTPS的工作原理。 - -34. 阐述Django项目中一个请求的生命周期。 - -35. Django项目中实现数据接口时如何解决跨域问题。 - -36. Django项目中如何对接Redis高速缓存服务。 - -37. 请说明Cookie和Session之间的关系。 - -38. 说一下索引的原理和作用。 - -39. 是否使用过Nginx实现负载均衡?用过哪些负载均衡算法? - -40. 一个保存整数(int)的数组,除了一个元素出现过1次外,其他元素都出现过两次,请找出这个元素。 - -41. 有12个外观相同的篮球,其中1个的重要和其他11个的重量不同(有可能轻有可能重),现在有一个天平可以使用,怎样才能通过最少的称重次数找出这颗与众不同的球。 \ No newline at end of file diff --git a/Day91-100/91.团队项目开发的问题和解决方案.md b/Day91-100/91.团队项目开发的问题和解决方案.md index 9cd9486..df2ac87 100644 --- a/Day91-100/91.团队项目开发的问题和解决方案.md +++ b/Day91-100/91.团队项目开发的问题和解决方案.md @@ -1,6 +1,6 @@ ## 团队项目开发的问题和解决方案 -我们经常听到个人开发和团队开发这两个词,所谓个人开发就是一个人把控产品的所有内容;而团队开发则是由多个人组团并完成产品的开发。要实施团队开发以下几点是必不可少的: +个人开发和团队开发这两个词相信对大家来说并不陌生。所谓个人开发就是一个人把控产品的所有内容;而团队开发则是由多个人组团并完成产品的开发。要实施团队开发以下几点是不可或缺的: 1. 对开发过程中的各种事件(例如:谁到什么时间完成了什么事情)进行管理和共享。 2. 在团队内部共享各类工作成果以及新的知识技巧等。 @@ -10,6 +10,8 @@ ### 团队项目开发常见问题 +团队开发相较于个人开发,容易遇到以下几个方面的问题。 + #### 问题1:传统的沟通方式无法确定处理的优先级 例如:使用邮件进行沟通可能出现邮件数量太多导致重要的邮件被埋没,无法管理状态,不知道哪些问题已经解决,哪些问题尚未处理,如果用全文检索邮件的方式来查询相关问题效率过于低下。 @@ -107,6 +109,8 @@ tar -xvf git-2.23.0.tar yum -y install libcurl-devel ``` +> 说明:没有这个依赖库,git的网络功能将无法执行。 + 安装前的配置。 ```Shell @@ -139,7 +143,7 @@ git init ![](./res/git_repository.png) -> **提示**:用`ls -la`查看所有文件会发现在执行完上面的命令后,文件夹下多了一个名为`.git`的隐藏文件夹,这个文件夹就是Git版本仓库。 +> **提示**:用`ls -la`查看所有文件会发现在执行完上面的命令后,文件夹下多了一个名为`.git`的隐藏文件夹,这个就是本地的Git版本仓库。 通过`git add`可以将指定的文件或所有文件添加到暂存区。 @@ -184,7 +188,7 @@ git commit -m '本次提交的说明' ```Shell git log -git log --graph --pretty=oneline --abbrev-commit +git log --graph --oneline --abbrev-commit ``` #### Git服务器概述 @@ -205,7 +209,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 ![](./res/gitee-add-members.png) -3. 项目的分支。创建项目后,项目只有一个默认的**master**分支,应该将该分支设置为“保护分支”来避免项目管理者之外的成员修改该分支。当然,如果需要我们也可以在线创建新的代码分支。 +3. 项目的分支。创建项目后,项目只有一个默认的**master**分支,应该将该分支设置为“保护分支”来避免项目管理者之外的成员修改该分支(不可直接提交)。当然,如果需要我们也可以在线创建新的代码分支。 4. 设置公钥实现免密访问。在项目的“设置”或“管理”中我们还可以找到“部署公钥管理”的选项,通过添加部署公钥,可以通过SSH(安全远程连接)的方式访问服务器而不用每次输入用户名和口令。可以使用`ssh-keygen`命令来创建密钥对。 @@ -237,8 +241,6 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 其中,`-u`是`--set-upstream`的缩写,用来指定推送的服务器仓库,后面的`origin`就是刚才给仓库起的简短的别名,冒号前面的`master`是本地分支名,冒号后面的`master`是远程分支名,如果本地分支`master`已经和远程分支`master`建立过关联,则冒号以及后面的部分可以省略。 - > **说明**:一般不能直接将工作成果push到`master`分支,因为它通常是一个受保护分支。 - 3. 从远程仓库取回代码。 ```Shell @@ -247,7 +249,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 #### Git分支操作 -1. 创建和切换分支。下面的命令创建了名为`dev` 的分支并切换到该分支。 +1. **创建**和**切换**分支。下面的命令创建了名为`dev` 的分支并切换到该分支。 ```Shell git branch @@ -262,7 +264,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 > **注意**:在之前的Git版本中,切换分支使用`git checkout `命令,也可以通过`git checkout -b `来创建并切换分支。`git switch`命令目前仍然处于试验性阶段,但很明显这个命令更加清晰的表达了它要做的事情。 -2. 关联远程分支。例如:如果当前所在的分支还没有关联到远程分支,可以使用下面的命令为它们建立关联。 +2. **关联远程**分支。例如:如果当前所在的分支还没有关联到远程分支,可以使用下面的命令为它们建立关联。 ```Shell git branch --set-upstream-to origin/develop @@ -288,7 +290,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 git branch --unset-upstream ``` -3. 分支合并。例如在`dev`分支上完成开发任务之后,如果希望将`dev`分支上的成果合并到`master`,可以先切回到`master`分支然后使用`git merge`来做分支合并,合并的结果如下图右上方所示。 +3. 分支**合并**。例如在`dev`分支上完成开发任务之后,如果希望将`dev`分支上的成果合并到`master`,可以先切回到`master`分支然后使用`git merge`来做分支合并,合并的结果如下图右上方所示。 ```Shell git switch master @@ -299,7 +301,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 在合并分支时,没有冲突的部分Git会做自动合并。如果发生了冲突(如`dev`和`master`分支上都修改了同一个文件),会看到`CONFLICT (content): Merge conflict in . Automatic merge failed; fix conflicts and then commit the result`(自动合并失败,修复冲突之后再次提交)的提示,这个时候我们可以用`git diff`来查看产生冲突的内容。解决冲突通常需要当事人当面沟通之后才能决定保留谁的版本,冲突解决后需要重新提交代码。 -4. 分支变基。分支合并操作可以将多个分支上的工作成果最终合并到一个分支上,但是再多次合并操作之后,分支可能会变得非常的混乱和复杂,为了解决这个问题,可以使用`git rebase`操作来实现分支变基。如下图所示,当我们希望将`master`和`dev`上的工作成果统一到一起的时候,也可以使用变基操作。 +4. 分支**变基**。分支合并操作可以将多个分支上的工作成果最终合并到一个分支上,但是再多次合并操作之后,分支可能会变得非常的混乱和复杂,为了解决这个问题,可以使用`git rebase`操作来实现分支变基。如下图所示,当我们希望将`master`和`dev`上的工作成果统一到一起的时候,也可以使用变基操作。 ![](./res/git-rebase.png) @@ -311,7 +313,7 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 当我们在`dev`分支执行`git rebase`命令时,将首先计算`dev`分支和`master`分支的差集,然后应用该差集到`dev`分支,最后我们切回到`master`分支并执行操作合并,这样就看到了如上图右下方所示的干净的分支。 -5. 删除分支。删除分支可以使用`git branch`加上`-d`参数,如果分支上的工作成果还没有合并,那么在删除分支时会看到`error: The branch '' is not fully merged.`这样的错误提示。如果希望强行删除分支,可以使用`-D`参数。删除分支的操作如下所示。 +5. **删除**分支。删除分支可以使用`git branch`加上`-d`参数,如果分支上的工作成果还没有合并,那么在删除分支时会看到`error: The branch '' is not fully merged.`这样的错误提示。如果希望强行删除分支,可以使用`-D`参数。删除分支的操作如下所示。 ```Shell git branch -d @@ -327,14 +329,31 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 git push origin :develop ``` + 或者 + + ```Shell + git push origin --delete develop + ``` + #### Git其他操作 1. `git fetch`:下载远程仓库的所有变动,可以将远程仓库下载到一个临时分支,然后再根据需要进行合并操作,`git fetch`命令和`git merge`命令可以看作是之前讲的`git pull`命令的分解动作。 + ```Shell + git fetch origin master:temp + git merge temp + ``` + 2. `git diff`:常用于比较工作区和仓库、暂存区与仓库、两个分支之间有什么差别。 3. `git stash`:将当前工作区和暂存区发生的变动放到一个临时的区域,让工作区变干净。这个命令适用于手头工作还没有提交,但是突然有一个更为紧急的任务(如线上bug需要修正)需要去处理的场景。 + ```Shell + git stash + git stash list + git stash pop + ``` + 4. `git reset`:回退到指定的版本。该命令主要有三个参数,如下图所示。 ![](./res/git-reset.png) @@ -363,6 +382,12 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 git switch -c ``` + 或 + + ```Shell + git checkout -b + ``` + 3. 在自己的分支上开发并在本地做版本控制。 4. 将自己的分支(工作成果)推到服务器。 @@ -402,21 +427,21 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 创建`feature`分支: ```Shell - git switch -c myfeature develop + git switch -c feature/user develop ``` 或 ```Shell - git checkout -b myfeature develop + git checkout -b feature/user develop ``` - 将`feature`分支合并到`develop`分支: + 接下来就是在`feature`分支上进行开发并实施版本控制,这一段如何操作我们就不再赘述了。工作完成后,将`feature`分支合并到`develop`分支: ```Shell git checkout develop - git merge --no-ff myfeature - git branch -d myfeature + git merge --no-ff feature/user + git branch -d feature/user git push origin develop ``` @@ -425,8 +450,10 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 创建`release`分支: ```Shell - git switch -c release-0.1 develop + git checkout -b release-0.1 develop + git push -u origin release-0.1 ... ... ... + git pull git commit -a -m "............" ``` @@ -435,12 +462,16 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 ```Shell git checkout master git merge --no-ff release-0.1 - git tag -a 0.1 + git push git checkout develop git merge --no-ff release-0.1 + git push git branch -d release-0.1 + git push --delete release-0.1 + git tag v0.1 master + git push --tags ``` 4. 从`master`分支创建`hotfix`分支,在修复bug后合并到`develop`和`master`分支(上图右下)。 @@ -449,8 +480,10 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 ```Shell git checkout -b hotfix-0.1.1 master + git push -u origin hotfix-0.1.1 ... ... ... - git commit -m "............" + git pull + git commit -a -m "............" ``` 将`hotfix`分支合并回`develop`和`master`分支。 @@ -458,15 +491,19 @@ Git不像SVN那样一定需要中央服务器才能工作,上面我们演示 ```Shell git checkout master git merge --no-ff hotfix-0.1.1 - git tag -a 0.1.1 + git push git checkout develop git merge --no-ff hotfix-0.1.1 + git push git branch -d hotfix-0.1.1 + git push --delete hotfix-0.1.1 + git tag v0.1.1 master + git push --tags ``` -Git-flow流程比较容易控制各个分支的状况,但是在运用上github-flow要复杂得多,因此实际使用的时候通常会安装名为`gitflow`的命令行工具或者使用图形化的Git工具(如:SmartGit、SourceTree等)来简化操作,具体的可以参考[《git-flow 的工作流程》]()一文,因为这篇文章写得已经很好了,本文不再进行赘述。 +Git-flow流程比较容易控制各个分支的状况,但是在运用上github-flow要复杂得多,因此实际使用的时候通常会安装名为`gitflow`的命令行工具(Windows环境的Git自带了该工具)或者使用图形化的Git工具(如:SmartGit、SourceTree等)来简化操作,具体的可以参考[《git-flow 的工作流程》]()一文,因为这篇文章写得已经很好了,本文不再进行赘述。 ### 缺陷管理 @@ -480,7 +517,7 @@ Git-flow流程比较容易控制各个分支的状况,但是在运用上github #### 禅道 -[禅道]()是国产的专业项目管理软件,它不仅仅是缺陷管理工具,它提供了完整软件生命周期管理功能,支持Scrum敏捷开发,能够实现需求管理、缺陷管理、任务管理等一系列的功能,而且拥有强大的扩展机制和丰富的功能插件。可以从禅道的官方网站提供的[下载链接]()来下载禅道,推荐使用一键安装包。 +[禅道]()是国产的专业项目管理软件,它不仅仅是缺陷管理工具,它提供了完整软件生命周期管理功能,支持[Scrum敏捷开发](),能够实现需求管理、缺陷管理、任务管理等一系列的功能,而且拥有强大的扩展机制和丰富的功能插件。可以从禅道的官方网站提供的[下载链接]()来下载禅道,推荐使用一键安装包。 下面仍然以CentOS Linux为例,讲解如何利用官方提供的一键安装包来安装禅道。 @@ -508,9 +545,11 @@ tar -xvf ZenTaoPMS.pro8.5.2.zbox_64.tar ![](./res/zentao-index.png) -#### Gitlab +对敏捷开发以及敏捷闭环工具不是特别了解的,可以参考[《基于JIRA的Scrum敏捷开发的项目管理》]()一文。 -一般的代码托管平台或者是我们之前提到的Git私服Gitlab都提供了缺陷管理的功能,当我们要报告一个bug时,可以在如下图所示的界面创建一个新的问题票(issue ticket)。填写的内容包括: +#### GitLab + +常用的代码托管平台和之前提到的Git私服Gitlab都提供了缺陷管理的功能,当我们要报告一个bug时,可以在如下图所示的界面创建一个新的问题票(issue ticket)。填写的内容包括: 1. **[必填]**出现问题的软件版本号、具体的使用环境(如操作系统)等相关信息。 2. **[必填]**能够稳定重现该问题的相关步骤。 @@ -538,13 +577,13 @@ tar -xvf ZenTaoPMS.pro8.5.2.zbox_64.tar ### 持续集成 -为了快速的产生高品质的软件,在团队开发中,持续集成(CI)也是一个非常重要的基础。按照经典的软件过程模型(瀑布模型),集成的工作一般要等到所有的开发工作都结束后才能开始,但这个时候如果发现了问题,修复问题的代价是非常具体的。基本上,集成实施得越晚,代码量越大,解决问题就越困难。持续集成将版本控制、自动化构建、代码测试融入到一起,让这些工作变得自动化和可协作。由于其频繁重复整个开发流程(在指定时间内多次pull源代码并运行测试代码),所以能帮助开发者提早发现问题。 +为了快速的产出高质量的软件,在团队开发中持续集成(CI)是一个非常重要的环节。所谓CI,就是一种让计算机自动任意次重复编译、测试、汇报等工作的方法,通过CI可以帮助开发者提早发现问题,降低各种人为失误给项目带来的风险。按照经典的软件过程模型(瀑布模型),集成的工作一般要等到所有的开发工作都结束后才能开始,但这个时候如果发现了问题,修复问题的代价是非常具体的。基本上,集成实施得越晚,代码量越大,解决问题就越困难。持续集成将版本控制、自动化构建、代码测试融入到一起,让这些工作变得自动化和可协作。由于其频繁重复整个开发流程(在指定时间内多次pull源代码并运行测试代码),所以能帮助开发者提早发现问题。 在所有的CI工具中,Jenkins和[TravisCI]()是最具有代表性的,前者是基于 Java的开源CI工具,后者是新晋的在线CI工具,下图是Jenkins的工作面板。 ![](./res/jenkins_new_project.png) -持续集成对于编译型语言的意义更大,对于Python这样的解释型语言,更多的时候是用于对接版本控制系统触发自动化测试并产生相应的报告。类似的功能也可以通过在Git服务上配置**Webhook**来完成,码云甚至可以直接对接[钉钉开放平台]()使用钉钉机器人来向项目相关人员发送即时消息。Gitlab也对CI和CD(持续交付)提供了支持,具体内容请大家参考[《GitLab CI/CD基础教程》]()。 +持续集成对于编译型语言的意义更大,对于Python这样的解释型语言,更多的时候是用于对接版本控制系统触发自动化测试并产生相应的报告,类似的功能也可以通过配置**Webhook**来完成。如果要通过Docker这样的虚拟化容器进行项目打包部署或者通过K8S进行容器管理,可以在持续集成平台安装对应的插件来支持这些功能。码云甚至可以直接对接[钉钉开放平台]()使用钉钉机器人来向项目相关人员发送即时消息。GitLab也对CI和CD(持续交付)提供了支持,具体内容请大家参考[《GitLab CI/CD基础教程》]()。 > **说明**: > diff --git a/Day91-100/92.使用Docker部署应用.md b/Day91-100/92.Docker容器详解.md similarity index 70% rename from Day91-100/92.使用Docker部署应用.md rename to Day91-100/92.Docker容器详解.md index 4be56ce..ebea4c6 100644 --- a/Day91-100/92.使用Docker部署应用.md +++ b/Day91-100/92.Docker容器详解.md @@ -1,4 +1,6 @@ -## 使用Docker部署应用 +## Docker容器详解 + +Docker是基于Go语言开发的开源应用容器引擎,遵从Apache Licence 2.0协议,可以让开发者打包应用以及应用的依赖包到一个可移植的容器中,然后发布到各种发行版本的Linux系统上。 ### Docker简介 @@ -8,7 +10,7 @@ 虚拟机(virtual machine)就是带环境安装的一种解决方案,它可以在一种操作系统里面运行另一种操作系统,比如在Windows系统里面运行Linux系统,在macOS上运行Windows,而应用程序对此毫无感知。使用过虚拟机的人都知道,虚拟机用起来跟真实系统一模一样,而对于虚拟机的宿主系统来说,虚拟机就是一个普通文件,不需要了就删掉,对宿主系统或者其他的程序并没有影响。但是虚拟机通常会占用较多的系统资源,启动和关闭也非常的缓慢,总之用户体验并没有想象中的那么好。 -Docker属于对Linux容器技术的一种封装(利用了Linux的namespace和cgroup技术),它提供了简单易用的容器使用接口,是目前最流行的 Linux 容器解决方案。Docker将应用程序与该程序的依赖打包在一个文件里面,运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。下图是虚拟机和容器的对比,左边是传统的虚拟机,右边是Docker。 +Docker属于对Linux容器技术(LXC)的一种封装(利用了Linux的namespace和cgroup技术),它提供了简单易用的容器使用接口,是目前最流行的 Linux 容器解决方案。Docker将应用程序与该程序的依赖打包在一个文件里面,运行这个文件,就会生成一个虚拟容器。程序在这个虚拟容器里运行,就好像在真实的物理机上运行一样。下图是虚拟机和容器的对比,左边是传统的虚拟机,右边是Docker。 ![](./res/docker_vs_vm.png) @@ -22,25 +24,49 @@ Docker属于对Linux容器技术的一种封装(利用了Linux的namespace和c 下面以CentOS为例讲解如何安装Docker,使用[Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/)、[macOS](https://docs.docker.com/docker-for-mac/install/)或[Windows](https://docs.docker.com/docker-for-windows/install/)的用户可以通过点击对应的链接了解这些平台下如何进行安装。 -1. 确定操作系统内核版本(CentOS 7要求64位,内核版本3.10+;CentOS 6要求64位,内核版本2.6+),可以通过下面的命令确定Linux系统内核版本。 +1. 确定操作系统内核版本(CentOS 7要求64位,内核版本3.10+;CentOS 6要求64位,内核版本2.6+)。 -```Shell -uname -r -``` + ```Bash + uname -r + ``` -2. 在CentOS下使用yum安装Docker并启动。 +2. 更新系统底层的库文件(建议一定要执行,否则在使用Docker时可能会出现莫名其妙的问题)。 -```Shell -yum -y install docker -systemctl start docker -``` + ```Bash + yum update + ``` -3. 查看Docker的信息和版本。 +3. 移除可能存在的旧的Docker版本。 -```Shell -docker version -docker info -``` + ```Bash + yum erase -y docker docker-common docker-engine + ``` + +4. 安装yum工具包和依赖项。 + + ```Bash + yum install -y yum-utils device-mapper-persistent-data lvm2 + ``` + +5. 通过yum工具包添加yum源(安装Docker-ce的源)。 + + ```Bash + yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + ``` + +6. 在CentOS下使用yum安装Docker-ce并启动。 + + ```Bash + yum -y install docker-ce + systemctl start docker + ``` + +7. 查看Docker的信息和版本。 + + ```Shell + docker version + docker info + ``` 接下来可以通过下载镜像和创建容器来看看Docker是否可以运转起来。可以使用下面的命令从Docker的镜像仓库下载名为hello-world的镜像文件。 @@ -112,7 +138,7 @@ docker rmi hello-world > > 国内用户可以通过更换Ubuntu软件下载源来提升下载速度,具体请参照清华大学开源软件镜像站上的[《Ubuntu镜像使用帮助》]()。 -安装Docker后,由于直接访问[dockerhub](https://hub.docker.com/)下载镜像会非常缓慢,建议将服务器更换为国内镜像,可以通过修改 `/etc/docker/daemon.js` 文件来做到。一般的云服务器会有自己专属的镜像,就不需要手动修改了。 +安装Docker后,由于直接访问[dockerhub](https://hub.docker.com/)下载镜像会非常缓慢,建议将服务器更换为国内镜像,可以通过修改 `/etc/docker/daemon.json` 文件来做到。一般的云服务器会有自己专属的镜像,就不需要手动修改了。 ```JavaScript { @@ -125,7 +151,7 @@ docker rmi hello-world ### 使用Docker -想要玩转Docker,最简单的办法就是马上用Docker创建一些自己学习和工作中需要用到的容器,接下来我们就带着大家一起来创建这些容器。 +想要玩转Docker,最简单的办法就是马上用Docker创建一些自己学习和工作中需要用到的容器,下面我们带着大家一起来创建这些容器。 #### 运行Nginx @@ -152,7 +178,7 @@ docker container stop mynginx 然后用下面的命令重新创建容器。 ```Shell -docker container run -d -p 80:80 --rm --name mynginx --volume $PWD/html:/usr/share/nginx/html nginx +docker container run -d -p 80:80 --rm --name mynginx --volume /root/docker/nginx/html:/usr/share/nginx/html nginx ``` > 说明:上面创建容器和拷贝文件的命令中,`container`是可以省略的,也就是说`docker container run`和`docker run`是一样的,而`docker container cp`和`docker cp`是一样的。此外,命令中的`--volume`也可以缩写为`-v`,就如同`-d`是`--detach`的缩写,`-p`是`--publish`的缩写。`$PWD`代表宿主系统当前文件夹,这些对于使用过Unix或者Linux系统的人来说,应该是很容易理解的。 @@ -230,7 +256,7 @@ docker.io/mysql 5.7 f6509bac4980 3 weeks ago 创建并运行MySQL容器。 ```Shell -docker run -d -p 3306:3306 --name mysql57 -v $PWD/mysql/conf:/etc/mysql/mysql.cnf.d -v $PWD/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7 +docker run -d -p 3306:3306 --name mysql57 -v /root/docker/mysql/conf:/etc/mysql/mysql.conf.d -v /root/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7 ``` > **注意**:上面创建容器时我们又一次使用了数据卷操作,那是因为通常容器是随时创建随时删除的,而数据库中的数据却是需要保留下来的。 @@ -298,7 +324,7 @@ select user, host, plugin, authentication_string from user where user='root'; 接下来我们试一试运行多个容器并让多个容器之间通过网络通信。我们创建4个Redis容器来实现一主三从的主从复制结构。 ```Shell -docker run -d -p 6379:6379 --name redis-master redis redis-server +docker run -d -p 6379:6379 --name redis-master redis docker run -d -p 6380:6379 --name redis-slave-1 --link redis-master:redis-master redis redis-server --replicaof redis-master 6379 docker run -d -p 6381:6379 --name redis-slave-2 --link redis-master:redis-master redis redis-server --replicaof redis-master 6379 docker run -d -p 6382:6379 --name redis-slave-3 --link redis-master:redis-master redis redis-server --replicaof redis-master 6379 @@ -335,9 +361,7 @@ repl_backlog_histlen:1988 #### 运行GitLab -GitLab是由GitLab Inc.开发的Git仓库管理工具,具有wiki、问题跟踪、持续集成等一系列的功能,分为社区版和企业版。通过Docker提供的虚拟化容器,我们可以安装社区版的Docker,命令如下所示。 - -因为GitLab需要使用SSH协议进行安全连接,我们要暴露容器的22端口,所以可以先将宿主机SSH连接的22端口修改为其他端口(如:12345),然后再进行后续的操作。 +GitLab是由GitLab Inc.开发的Git仓库管理工具,具有wiki、问题跟踪、持续集成等一系列的功能,分为社区版和企业版。通过Docker提供的虚拟化容器,我们可以安装社区版的Docker。因为GitLab需要使用SSH协议进行安全连接,我们要暴露容器的22端口,所以可以先将宿主机SSH连接的22端口修改为其他端口(如:12345),然后再进行后续的操作。 ```Shell vim /etc/ssh/sshd_config @@ -360,9 +384,7 @@ systemctl restart sshd 创建需要用于数据卷映射操作的文件夹。 ```Shell -mkdir -p /root/gitlab/config -mkdir -p /root/gitlab/logs -mkdir -p /root/gitlab/data +mkdir -p /root/gitlab/{config,logs,data} ``` 基于`gitlab/gitlab-ce`镜像创建容器,并暴露80端口(HTTP连接)和22端口(SSH连接)。 @@ -377,7 +399,7 @@ docker run -d -p 80:80 -p 22:22 --name gitlab -v /root/gitlab/config:/etc/gitlab ### 构建镜像 -通过上面的讲解,我们已经掌握了如何通过官方提供的镜像来创建容器。当然如果愿意,我们也可以用配置好的容器来生成镜像。简而言之,Docker镜像是由文件系统叠加而成的,系统的最底层是bootfs,相当于就是Linux内核的引导文件系统;接下来第二层是rootfs,这一层可以是一种或多种操作系统(如Debian或Ubuntu文件系统),Docker中的rootfs是只读状态的;Docker利用联合挂载技术将各层文件系统叠加到一起,最终的文件系统会包含有底层的文件和目录,这样的文件系统就是一个镜像。 +通过上面的讲解,我们已经掌握了如何通过官方提供的镜像来创建容器。当然如果愿意,我们也可以用配置好的容器来生成镜像。简而言之,**Docker镜像是由文件系统叠加而成的,系统的最底层是bootfs,相当于就是Linux内核的引导文件系统;接下来第二层是rootfs,这一层可以是一种或多种操作系统(如Debian或Ubuntu文件系统),Docker中的rootfs是只读状态的;Docker利用联合挂载技术将各层文件系统叠加到一起,最终的文件系统会包含有底层的文件和目录,这样的文件系统就是一个镜像**。 之前我们讲过了如何查找、列出镜像和拉取(下载)镜像,接下来看看构建镜像的两种方式: @@ -437,25 +459,77 @@ jackfrued/mywebserver latest 795b294d265a 14 seconds ago 189 MB Dockerfile使用DSL(Domain Specific Language)来构建一个Docker镜像,只要编辑好了Dockerfile文件,就可以使用`docker build`命令来构建一个新的镜像。 -我们先创建一个空文件夹并在文件夹下创建名为Dockerfile的文件。 +我们先创建一个名为myapp的文件夹来保存项目代码和Dockerfile的文件,如下所示: ```Shell -touch Dockerfile +[ECS-root temp]# tree myapp +myapp +├── api +│ ├── app.py +│ ├── requirements.txt +│ └── start.sh +└── Dockerfile ``` -编辑这个Dockerfile文件添加如下所示的内容。 +其中api是Flask项目的文件夹,其中包括了项目代码、依赖项以及启动脚本等文件,具体内容如下所示: + +app.py文件: + +```Python +from flask import Flask +from flask_restful import Resource, Api +from flask_cors import CORS + +app = Flask(__name__) +CORS(app, resources={r'/api/*': {'origins': '*'}}) +api = Api(app) + + +class Product(Resource): + + def get(self): + products = ['Ice Cream', 'Chocolate', 'Coca Cola', 'Hamburger'] + return {'products': products} + + +api.add_resource(Product, '/api/products') +``` + +requirements.txt文件: + +```INI +flask +flask-restful +flask-cors +gunicorn +``` + +start.sh文件: ```Shell -vim Dockerfile +#!/bin/bash +exec gunicorn -w 4 -b 0.0.0.0:8000 app:app ``` +> **提示**:需要给start.sh文件以执行权限,可以使用`chmod 755 start.sh`命令来做到。 + +Dockerfile文件: + ```Dockerfile -# version: 0.0.1 -FROM ubuntu:14.04 +# 指定基础镜像 +FROM python:3.7 +# 指定镜像的维护者 MAINTAINER jackfrued "jackfrued@126.com" -RUN apt-get update && apt-get install -y nginx -RUN echo 'hello, world!' > /usr/share/nginx/html/index.html -EXPOSE 80 +# 将指定文件添加到容器中指定的位置 +ADD api/* /root/api/ +# 设置工作目录 +WORKDIR /root/api +# 执行命令(安装Flask项目的依赖项) +RUN pip install -r requirements.txt -i https://pypi.doubanio.com/simple/ +# 容器启动时要执行的命令 +ENTRYPOINT ["./start.sh"] +# 暴露端口 +EXPOSE 8000 ``` 我们来解释一下上面的Dockerfile文件。Dockerfile文件通过特殊的指令来指定基础镜像(FROM指令)、创建容器后需要指定的命令(RUN指令)以及需要暴露的端口(EXPOSE)等信息。我们稍后会专门为大家介绍这些Dockfile中的指令。 @@ -463,7 +537,7 @@ EXPOSE 80 接下来我们可以使用`docker build`命令来创建镜像,如下所示。 ```Shell -docker build -t="jackfrued/webserver" . +docker build -t "jackfrued/myapp" . ``` > 提示:上面的命令最后面的`.` 千万不要漏掉了哦,它表示从当前路径下寻找Dockerfile。 @@ -475,34 +549,31 @@ docker images ``` ``` -REPOSITORY TAG IMAGE ID CREATED SIZE -jackfrued/webserver latest 87d6cb096be2 23 minutes ago 222 MB +REPOSITORY TAG IMAGE ID CREATED SIZE +jackfrued/myapp latest 6d6f026a7896 5 seconds ago 930 MB ``` 如果想知道镜像文件是如何创建出来的,可以使用下面的命令。 ```Shell -docker history jackfrued/webserver +docker history jackfrued/myapp ``` ``` -IMAGE CREATED CREATED BY SIZE -87d6cb096be2 25 minutes ago /bin/sh -c #(nop) EXPOSE 80/tcp 0 B -53d3bc3a123e 25 minutes ago /bin/sh -c service nginx start 3 B -10646b63275e 25 minutes ago /bin/sh -c echo 'hello, world!' > /usr/sha... 14 B -f3e3bf3e998e 25 minutes ago /bin/sh -c apt-get update && apt-get insta... 34.3 MB -c98e22cf5a64 26 minutes ago /bin/sh -c #(nop) MAINTAINER jackfrued "j... 0 B -2c5e00d77a67 3 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B - 3 months ago /bin/sh -c mkdir -p /run/systemd && echo '... 7 B - 3 months ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0 B - 3 months ago /bin/sh -c set -xe && echo '#!/bin/sh' >... 195 kB - 3 months ago /bin/sh -c #(nop) ADD file:1e01ab604c0cc30... 188 MB +IMAGE CREATED CREATED BY SIZE COMMENT +6d6f026a7896 31 seconds ago /bin/sh -c #(nop) EXPOSE 8000/tcp 0 B +3f7739173a79 31 seconds ago /bin/sh -c #(nop) ENTRYPOINT ["./start.sh"] 0 B +321e6bf09bf1 32 seconds ago /bin/sh -c pip install -r requirements.txt... 13 MB +2f9bf2c89ac7 37 seconds ago /bin/sh -c #(nop) WORKDIR /root/api 0 B +86119afbe1f8 37 seconds ago /bin/sh -c #(nop) ADD multi:4b76f9c9dfaee8... 870 B +08d465e90d4d 3 hours ago /bin/sh -c #(nop) MAINTAINER jackfrued "j... 0 B +fbf9f709ca9f 12 days ago /bin/sh -c #(nop) CMD ["python3"] 0 B ``` 使用该镜像来创建容器运行Web服务器。 ```Shell -docker run -d -p 80:80 --name mywebserver jackfrued/webserver nginx -g "daemon off;" +docker run -d -p 8000:8000 --name myapp jackfrued/myapp ``` 如果希望将上面创建的镜像文件放到dockerhub仓库中,可以按照如下所示的步骤进行操作。 @@ -610,7 +681,7 @@ docker push jackfrued/webserver USER nginx ``` -8. **VOLUME**:在创建容器时添加一个数据卷的挂载点。通过数据卷操作可以实现容器间数据的共享和重用,对卷所作的修改可以马上生效而不需要重新启动容器,我们之前创建容器时使用`—volume`参数就是为了实现数据卷的映射操作。 +8. **VOLUME**:在创建容器时添加一个数据卷的挂载点。通过数据卷操作可以实现容器间数据的共享和重用,对卷所作的修改可以马上生效而不需要重新启动容器,我们之前创建容器时使用`--volume`参数就是为了实现数据卷的映射操作。 ```Dockerfile VOLUME ["/路径1", "/路径2/子路径2.1/", ...] @@ -637,7 +708,7 @@ docker push jackfrued/webserver ONBUILD RUN cd /app/src && make ``` -### 容器编排 +### 多容器管理 我们的项目可能会使用了多个容器,容器多了之后管理容器的工作就会变得麻烦。如果要对多个容器进行自动配置使得容器可以相互协作甚至实现复杂的调度,这就需要进行容器编排。Docker原生对容器编排的支持非常弱,但是可以通过社区提供的工具来实现容器编排。 @@ -648,7 +719,7 @@ docker push jackfrued/webserver 1. 安装Docker Compose。 ```Shell - curl -L https://github.com/docker/compose/releases/download/1.25.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose + curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose ``` @@ -662,30 +733,31 @@ docker push jackfrued/webserver 2. 使用Docker Compose。 - 我们先创建一个名为`composeapp`的文件夹并在该文件夹下创建两个子文件夹`product-service`和`web-site`,如下所示。 + 我们在刚才的Flask项目中引入缓存,然后再利用Flask提供的数据接口为前端页面提供数据,使用Vue.js进行页面渲染并将静态页面部署在Nginx服务器上。项目文件夹结构如下所示: ```Shell - mkdir composeapp - cd composeapp - mkdir product-service - mkdir web-site + [ECS-root ~]# tree temp + temp + ├── docker-compose.yml + ├── html + │ └── index.html + └── myapp + ├── api + │ ├── app.py + │ ├── requirements.txt + │ └── start.sh + └── Dockerfile ``` - 我们先在`product-service`文件夹下编写提供数据的API接口程序。 - - ```Shell - vim product-service/api.py - ``` - - 我们用Flask来实现一个非常简单的数据接口服务程序。 + 修改后的app.py文件代码如下所示: ```Python from pickle import dumps, loads from flask import Flask from flask_restful import Resource, Api - from redis import Redis from flask_cors import CORS + from redis import Redis app = Flask(__name__) CORS(app, resources={r'/api/*': {'origins': '*'}}) @@ -697,52 +769,18 @@ docker push jackfrued/webserver def get(self): data = redis.get('products') - if not data: + if data: + products = loads(data) + else: products = ['Ice Cream', 'Chocolate', 'Coca Cola', 'Hamburger'] redis.set('products', dumps(products)) - else: - products = loads(data) return {'products': products} api.add_resource(Product, '/api/products') - - if __name__ == '__main__': - app.run(host='0.0.0.0', port=8000, debug=True) ``` - 由于上面的项目需要依赖`flask`、 `flask-restful`等三方库,所以我们再添加一个指明依赖库的文件并将其命名为`requirements.txt`,其内容如下所示。 - - ```Shell - vim product-service/requirements.txt - ``` - - ``` - flask - flask-restful - flask-cors - redis - ``` - - 稍后我们会将上面的接口服务放在一个容器中运行,为此我们先编写一个Dockerfile文件以便创建对应的镜像,其内容如下所示。 - - ```Shell - vim product-service/Dockerfile - ``` - - ```Dockerfile - FROM python:3 - ADD . /root/product-service - WORKDIR /root/product-service - RUN pip install -r requirements.txt - CMD ["python", "api.py"] - ``` - - 我们再去到`web-site`目录下创建一个页面,稍后我们会通一个容器来提供Nginx服务并运行该页面,而这个页面会访问我们刚才部署的数据接口服务获取数据并通过Vue.js将数据渲染到页面上。 - - ```Shell - vim web-site/index.html - ``` + html文件夹用来保存静态页面,稍后我们会通一个运行Nginx的容器来向浏览器提供静态页面。index.html文件的内容如下所示: ```HTML @@ -776,68 +814,63 @@ docker push jackfrued/webserver ``` - 接下来,我们要通过一个YAML文件来创建三个容器并指明容器之间的依赖关系。 - - ```Shell - vim docker-compose.yml - ``` + 接下来,我们要通过docker-compose.yml文件来创建三个容器并指明容器之间的依赖关系。 ```YAML version: '3' services: - - product-service: - build: ./product-service + api-server: + build: ./myapp ports: - '8000:8000' links: - redis-master - - web-site: + web-server: image: nginx ports: - '80:80' volumes: - - ./web-site:/usr/share/nginx/html - + - ./html:/usr/share/nginx/html redis-master: image: redis expose: - '6379' ``` - 有了这个YAML文件,我们就可以使用`docker-compose`命令来创建和管理这三个容器,其命令如下所示。 + 有了这个YAML文件,我们就可以使用`docker-compose`命令来创建容器运行项目,其命令如下所示: ```Shell - docker-compose up + [ECS-root temp]# docker-compose up + Creating network "temp_default" with the default driver + Creating temp_web-server_1 ... done + Creating temp_redis-master_1 ... done + Creating temp_api-server_1 ... done + Attaching to temp_redis-master_1, temp_web-server_1, temp_api-server_1 + redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo + redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # Redis version=5.0.6, bits=64, commit=00000000, modified=0, pid=1, just started + redis-master_1 | 1:C 05 Dec 2019 11:57:26.828 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf + redis-master_1 | 1:M 05 Dec 2019 11:57:26.830 * Running mode=standalone, port=6379. + redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. + redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # Server initialized + redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. + redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. + redis-master_1 | 1:M 05 Dec 2019 11:57:26.831 * Ready to accept connections + api-server_1 | [2019-12-05 11:57:27 +0000] [1] [INFO] Starting gunicorn 20.0.4 + api-server_1 | [2019-12-05 11:57:27 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1) + api-server_1 | [2019-12-05 11:57:27 +0000] [1] [INFO] Using worker: sync + api-server_1 | [2019-12-05 11:57:27 +0000] [8] [INFO] Booting worker with pid: 8 + api-server_1 | [2019-12-05 11:57:27 +0000] [9] [INFO] Booting worker with pid: 9 + api-server_1 | [2019-12-05 11:57:27 +0000] [10] [INFO] Booting worker with pid: 10 + api-server_1 | [2019-12-05 11:57:27 +0000] [11] [INFO] Booting worker with pid: 11 ``` - ``` - Creating network "composeapp_default" with the default driver - Building product-service - Step 1/5 : FROM python:3 - ---> e497dabd8450 - Step 2/5 : ADD . /root/product-service - ---> fbe62813d595 - Removing intermediate container 6579e845565a - Step 3/5 : WORKDIR /root/product-service - ---> 3a722675e3b1 - Removing intermediate container 57fc490436ce - Step 4/5 : RUN pip install -r requirements.txt - ---> Running in cadc2d0c1b9b - ... ... - ---> fc747fc11f4a - Removing intermediate container cadc2d0c1b9b - Step 5/5 : CMD python api.py - ---> Running in ecbbd2a69906 - ---> 637e760f2e5b - Removing intermediate container ecbbd2a69906 - Successfully built 637e760f2e5b - WARNING: Image for service product-service was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`. - Creating composeapp_redis-master_1 ... done - Creating composeapp_web-site_1 ... done - Creating composeapp_product-service_1 ... done - Attaching to composeapp_redis-master_1, composeapp_web-site_1, composeapp_product-service_1 - ... ... + 要停止容器的运行,可以使用下面的命令。 + + ```Shell + docker-compose down ``` +#### Kubernetes(K8S) + +实际的生产环境中常常需要部署和管理多个协同工作的容器,docker compose解决了多容器创建和管理的问题,但是实际项目中,我们还需要Kubernetes(以下都简称为K8S)来提供一个跨主机集群的容器调度平台。K8S可以进行自动化容器的部署、扩展和操作,从而提供以容器为中心的基础架构。该项目是谷歌在2014年启动的项目,建立在谷歌公司十余年运维经验的基础之上,而且谷歌自己的应用也是运行在容器上的。 + diff --git a/Day91-100/93.MySQL性能优化.md b/Day91-100/93.MySQL性能优化.md index 65e6e10..80caeca 100644 --- a/Day91-100/93.MySQL性能优化.md +++ b/Day91-100/93.MySQL性能优化.md @@ -17,8 +17,6 @@ 过程,通常也称之为存储过程,它是事先编译好存储在数据库中的一组SQL的集合。调用存储过程可以简化应用程序开发人员的工作,减少与数据库服务器之间的通信,对于提升数据操作的性能是有帮助的,这些我们在之前的[《关系型数据库MySQL》](../Day36-40/36-38.关系型数据库MySQL.md)一文中已经提到过。 - - ### 数据分区 MySQL支持做数据分区,通过分区可以存储更多的数据、优化查询,获得更大的吞吐量并快速删除过期的数据。关于这个知识点建议大家看看MySQL的[官方文档](https://dev.mysql.com/doc/refman/5.7/en/partitioning-overview.html)。数据分区有以下几种类型: @@ -60,19 +58,54 @@ MySQL支持做数据分区,通过分区可以存储更多的数据、优化查 ### SQL优化 -1. 通过`show status`了解各种SQL的执行频率。 +1. 定位低效率的SQL语句 - 慢查询日志。 - ```SQL - + - 查看慢查询日志相关配置 + + ```SQL + mysql> show variables like 'slow_query%'; + +---------------------------+----------------------------------+ + | Variable_name | Value | + +---------------------------+----------------------------------+ + | slow_query_log | OFF | + | slow_query_log_file | /mysql/data/localhost-slow.log | + +---------------------------+----------------------------------+ + + mysql> show variables like 'long_query_time'; + +-----------------+-----------+ + | Variable_name | Value | + +-----------------+-----------+ + | long_query_time | 10.000000 | + +-----------------+-----------+ + ``` + + - 创建慢查询日志文件并修改所有者。 + + ```Bash + touch /var/log/mysqld-slow.log + chown mysql /var/log/mysqld-slow.log + ``` + + - 修改全局慢查询日志配置。 + + ```SQL + mysql> set global slow_query_log_file='/var/log/mysqld-slow.log' + mysql> set global slow_query_log='ON'; + mysql> set global long_query_time=1; ``` + + 或者直接修改MySQL配置文件启用慢查询日志。 + + ```INI + [mysqld] + slow_query_log=ON + slow_query_log_file=/var/log/mysqld-slow.log + long_query_time=1 + ``` -2. 定位低效率的SQL语句 - 慢查询日志。 + > **注意**:修改了配置文件需要重启MySQL,CentOS上对应的命令是`systemctl restart mysqld`。 - ```SQL - show processlist - ``` - -3. 通过`explain`了解SQL的执行计划。例如: +2. 通过`explain`了解SQL的执行计划。例如: ```SQL explain select ename, job, sal from tb_emp where dno=20\G @@ -99,26 +132,101 @@ MySQL支持做数据分区,通过分区可以存储更多的数据、优化查 - `rows`:扫描的行数,行数越少肯定性能越好。 - `extra`:额外信息。 -4. 通过`show profiles`和`show profile for query`分析SQL。 +3. 通过`show profiles`和`show profile for query`分析SQL。 -5. 优化CRUD操作。 + MySQL从5.0.37开始支持剖面系统来帮助用户了解SQL执行性能的细节,可以通过下面的方式来查看MySQL是否支持和开启了剖面系统。 + + ```SQL + select @@have_profiling; + select @@profiling; + ``` + + 如果没有开启剖面系统,可以通过下面的SQL来打开它。 + + ```SQL + set profiling=1; + ``` + + 接下来就可以通过剖面系统来了解SQL的执行性能,例如: + + ```SQL + mysql> select count(*) from tb_emp; + +----------+ + | count(*) | + +----------+ + | 14 | + +----------+ + 1 row in set (0.00 sec) + + mysql> show profiles; + +----------+------------+-----------------------------+ + | Query_ID | Duration | Query | + +----------+------------+-----------------------------+ + | 1 | 0.00029600 | select count(*) from tb_emp | + +----------+------------+-----------------------------+ + 1 row in set, 1 warning (0.00 sec) + + mysql> show profile for query 1; + +----------------------+----------+ + | Status | Duration | + +----------------------+----------+ + | starting | 0.000076 | + | checking permissions | 0.000007 | + | Opening tables | 0.000016 | + | init | 0.000013 | + | System lock | 0.000007 | + | optimizing | 0.000005 | + | statistics | 0.000012 | + | preparing | 0.000010 | + | executing | 0.000003 | + | Sending data | 0.000070 | + | end | 0.000012 | + | query end | 0.000008 | + | closing tables | 0.000012 | + | freeing items | 0.000032 | + | cleaning up | 0.000013 | + +----------------------+----------+ + 15 rows in set, 1 warning (0.00 sec) + ``` + +4. 优化CRUD操作。 - 优化`insert`语句 - 在`insert`语句后面跟上多组值进行插入在性能上优于分开`insert`。 - 如果有多个连接向同一个表插入数据,使用`insert delayed`可以获得更好的性能。 - 如果要从一个文本文件装载数据到表时,使用`load data infile`比`insert`性能好得多。 + - 优化`order by`语句 + - 如果`where`子句的条件和`order by`子句的条件相同,而且排序的顺序与索引的顺序相同,如果还同时满足排序字段都是升序或者降序,那么只靠索引就能完成排序。 + - 优化`group by`语句 + - 在使用`group by`子句分组时,如果希望避免排序带来的开销,可以用`order by null`禁用排序。 + - 优化嵌套查询 + + - MySQL从4.1开始支持嵌套查询(子查询),这使得可以将一个查询的结果当做另一个查询的一部分来使用。在某些情况下,子查询可以被更有效率的连接查询取代,因为在连接查询时MySQL不需要在内存中创建临时表来完成这个逻辑上需要多个步骤才能完成的查询。 + - 优化or条件 + - 如果条件之间是`or`关系,则只有在所有条件都用到索引的情况下索引才会生效。 + - 优化分页查询 + + - 分页查询时,一个比较头疼的事情是如同`limit 1000, 20`,此时MySQL已经排序出前1020条记录但是仅仅返回第1001到1020条记录,前1000条实际都用不上,查询和排序的代价非常高。一种常见的优化思路是在索引上完成排序和分页的操作,然后根据返回的结果做表连接操作来得到最终的结果,这样可以避免出现全表查询,也避免了外部排序。 + + ```SQL + select * from tb_emp order by ename limit 1000, 20; + select * from tb_emp t1 inner join (select eno from tb_emp order by ename limit 1000, 20) t2 on t1.eno=t2.eno; + ``` + + 上面的代码中,第2行SQL是优于第1行SQL的,当然我们的前提是已经在`ename`字段上创建了索引。 + - 使用SQL提示 - - USE INDEX - - IGNORE INDEX - - FORCE INDEX + - USE INDEX:建议MySQL使用指定的索引。 + - IGNORE INDEX:建议MySQL忽略掉指定的索引。 + - FORCE INDEX:强制MySQL使用指定的索引。 ### 配置优化 @@ -141,24 +249,33 @@ show status like 'connections'; show status like 'slow_queries'; ``` -1. 调整max_connections -2. 调整back_log -3. 调整table_open_cache -4. 调整thread_cache_size -5. 调整innodb_lock_wait_timeout -6. 调整`innodb_buffer_pool_size`:InnoDB数据和索引的内存缓冲区大小,以字节为单位,这个值设置得越高,访问表数据需要进行的磁盘I/O操作就越少,如果可能甚至可以将该值设置为物理内存大小的80%。 +1. 调整`max_connections`:MySQL最大连接数量,默认151。在Linux系统上,如果内存足够且不考虑用户等待响应时间这些问题,MySQL理论上可以支持到万级连接,但是通常情况下,这个值建议控制在1000以内。 +2. 调整`back_log`:TCP连接的积压请求队列大小,通常是max_connections的五分之一,最大不能超过900。 +3. 调整`table_open_cache`:这个值应该设置为max_connections的N倍,其中N代表每个连接在查询时打开的表的最大个数。 +4. 调整`innodb_lock_wait_timeout`:该参数可以控制InnoDB事务等待行锁的时间,默认值是50ms,对于反馈响应要求较高的应用,可以将这个值调小避免事务长时间挂起;对于后台任务,可以将这个值调大来避免发生大的回滚操作。 +5. 调整`innodb_buffer_pool_size`:InnoDB数据和索引的内存缓冲区大小,以字节为单位,这个值设置得越高,访问表数据需要进行的磁盘I/O操作就越少,如果可能甚至可以将该值设置为物理内存大小的80%。 ### 架构优化 1. 通过拆分提高表的访问效率。 - 垂直拆分 - 水平拆分 + 2. 逆范式理论。数据表设计的规范程度称之为范式(Normal Form),要提升表的规范程度通常需要将大表拆分为更小的表,范式级别越高数据冗余越小,而且在插入、删除、更新数据时出问题的可能性会大幅度降低,但是节省了空间就意味着查询数据时可能花费更多的时间,原来的单表查询可能会变成连表查询。为此,项目实践中我们通常会进行逆范式操作,故意降低范式级别增加冗余来减少查询的时间开销。 - 1NF:列不能再拆分 - 2NF:所有的属性都依赖于主键 - 3NF:所有的属性都直接依赖于主键(消除传递依赖) - BCNF:消除非平凡多值依赖 + 3. 使用中间表提高统计查询速度。 + + 使用`insert into 中间表 select ... where ...`这样的语句先将需要的数据筛选出来放到中间表中,然后再对中间表进行统计,避免不必要的运算和处理。 + 4. 主从复制和读写分离,具体内容请参考[《项目部署上线和性能调优》](./98.项目部署上线和性能调优.md)。 + 5. 配置MySQL集群。 + + +> **说明**:本章内容参考了网易出品的《深入浅出MySQL》一书,该书和《高性能MySQL》一样,都对MySQL进行了深入细致的讲解,虽然总体感觉后者更加高屋建瓴,但是前者也算得上是提升MySQL技能的佳作(作者的文字功底稍显粗糙,深度也不及后者),建议有兴趣的读者可以阅读这两本书。 + diff --git a/Day91-100/94.网络API接口设计.md b/Day91-100/94.网络API接口设计.md index 22b20a9..9fddaff 100644 --- a/Day91-100/94.网络API接口设计.md +++ b/Day91-100/94.网络API接口设计.md @@ -1,12 +1,14 @@ ## 网络API接口设计 -目前许多的Web应用和移动应用都使用了前后端分离的开发模式,前后端分离简单的说就是前端或移动端通过网络API接口和后台进行交互。API是应用程序的编程接口的缩写;网络API通常指的是基于一个URL(统一资源定位符)可以访问到的资源,也就是说通过这个URL我们可以让服务器对某个资源进行操作并返回操作的结果,复杂的业务逻辑被隐藏在简单的API接口中。URL的通用格式如下所示: +目前许多的Web应用和移动应用都使用了前后端分离的开发模式,前后端分离简单的说就是前端或移动端通过网络API接口和后台进行交互,获得接口中提供的数据并负责用户界面的渲染。API是应用程序的编程接口的缩写,网络API通常指的是基于一个URL(统一资源定位符)可以访问到的资源,也就是说通过这个URL我们就可以请求服务器对某个资源进行操作并返回操作的结果。大家可以想想,网络API接口不也是一种封装吗,简单的说就是将复杂的业务逻辑隐藏在简单的API接口中。 + +URL的通用格式如下所示: ``` 协议://用户名:口令@主机:端口/路径1/.../路径N/资源名 ``` -> 说明:URL中的用户名(有可能不需要提供用户名)、口令(有可能不需要提供口令)、端口(有可能使用默认端口)、路径(资源有可能直接位于根路径`/`下)并不是必需的部分,可以根据需要进行设置。 +> **说明**:URL中的用户名(有可能不需要提供用户名)、口令(有可能不需要提供口令)、端口(有可能使用默认端口)、路径(资源有可能直接位于根路径`/`下)并不是必需的部分,可以根据需要进行设置。 网络API通常基于HTTP或HTTPS进行访问,基于HTTP/HTTPS最大的好处就在于访问起来非常的简单方便,而且可以跨语言、跨应用进行访问和互操作。 @@ -14,7 +16,7 @@ #### 关键问题 -为移动端或者PC端设计网络API接口一个非常重要的原则是:根据业务实体而不是用户界面或操作来设计。如果API接口的设计是根据用户的操作或者界面上的功能设置来设计,随着需求的变更,用户界面也会进行调整,需要的数据也在发生变化,那么后端开发者就要不停的调整API,或者给一个API设计出多个版本,这些都会使项目的开发和维护成本增加。 +为移动端或者PC端设计网络API接口一个非常重要的原则是:**根据业务实体而不是用户界面或操作来设计API接口**。如果API接口的设计是根据用户的操作或者界面上的功能设置来设计,随着需求的变更,用户界面也会进行调整,需要的数据也在发生变化,那么后端开发者就要不停的调整API,或者给一个API设计出多个版本,这些都会使项目的开发和维护成本增加。我们可以将业务实体理解为服务器提供的资源,而URL就是资源的定位符(标识符),这种方式是最为简单自然的。对于相对复杂的用户操作,我们可以提供一个“门面”(设计模式中的“门面模式”),通过该“门面”把多个接口的功能组装起来即可。 下面是某个网站开放API的接口,可以看出API的设计是围绕业务实体来进行的,而且都做到了“见名知意”。 @@ -28,9 +30,9 @@ | comments/destroy | 删除一条评论 | | comments/reply | 回复一条评论 | -需要说明的是,上面的API接口并不是REST风格的。REST是一种网络应用架构风格,被认为最适合分布式的网络应用。关于REST的知识,可以阅读阮一峰老师的[《理解RESTful架构》](http://www.ruanyifeng.com/blog/2011/09/restful.html)以及[《RESTful API设计指南》](http://www.ruanyifeng.com/blog/2014/05/restful_api.html),当然这两篇文章大家也要批判的阅读,因为上面阐述的观点并不完全正确,有些内容甚至是自相矛盾的。 +需要说明的是,**上面的API接口并不是REST风格的**。REST是一种网络应用架构风格,被认为最适合分布式的网络应用。关于REST的知识,可以阅读阮一峰的[《理解RESTful架构》](http://www.ruanyifeng.com/blog/2011/09/restful.html)以及[《RESTful API设计指南》](http://www.ruanyifeng.com/blog/2014/05/restful_api.html),当然这两篇文章大家也要批判的阅读,因为上面阐述的观点并不完全正确,有些内容甚至是自相矛盾的。 -API接口返回的数据通常都是**JSON**或**XML**格式,我们这里不会讲述XML的知识,因为这种格式几乎已经被淘汰掉了。对于JSON格式的数据,我们需要做到不要返回null这的值,因为这样的值一旦处置失当,会给前端和移动端开发带来不必要的麻烦(因为开发者有可能会使用强类型语言)。要解决这个问题可以从源头入手,在设计数据库的时候,尽量给每个字段都加上“not null”约束或者设置合理的默认值约束。 +API接口返回的数据通常都是**JSON**或**XML**格式,XML这种数据格式目前基本已经被弃用了。对于JSON格式的数据,我们需要做到不要返回null这的值,因为这样的值一旦处置失当,会给前端和移动端开发带来不必要的麻烦(因为开发者有可能会使用强类型语言)。要解决这个问题可以从源头入手,在设计数据库的时候,尽量给每个字段都加上“not null”约束或者设置合理的默认值约束。 #### 其他问题 @@ -42,9 +44,7 @@ API接口返回的数据通常都是**JSON**或**XML**格式,我们这里不 下面以设计评论接口为例,简单说明接口文档应该如何撰写。 -#### 评论接口 - -全局返回状态码 +首先,我们可以定义全局返回状态码。 | 返回码 | 返回信息 | 说明 | | ------ | ------------ | ---------------------------------- | @@ -54,7 +54,9 @@ API接口返回的数据通常都是**JSON**或**XML**格式,我们这里不 | 10003 | 评论已被删除 | 查看评论时评论因不和谐因素已被删除 | | 10004 | …… | …… | -1. **GET** `/articles/{article-id}/comments/` +1. 获取文章评论。 + + **GET** `/articles/{article-id}/comments/` 开发者:王大锤 @@ -103,7 +105,9 @@ API接口返回的数据通常都是**JSON**或**XML**格式,我们这里不 } ``` -2. **POST** `/articles/{article-id}/comments` +2. 新增文章评论。 + + **POST** `/articles/{article-id}/comments` 开发者:王大锤 @@ -137,3 +141,8 @@ API接口返回的数据通常都是**JSON**或**XML**格式,我们这里不 /* ... */ } ``` + + + +> **提示**:如果没有接口文档撰写经验,可以使用在线接口文档编辑平台[RAP2]()或[YAPI]()来进行接口文档撰写。 + diff --git a/Day91-100/95.使用Django开发商业项目.md b/Day91-100/95.使用Django开发商业项目.md index 26bdf40..8c3f7a2 100644 --- a/Day91-100/95.使用Django开发商业项目.md +++ b/Day91-100/95.使用Django开发商业项目.md @@ -1,6 +1,6 @@ ## 使用Django开发商业项目 -> 说明:本文的部分插图来自于《Python项目开发实战》和《精通Django》,这两本书中都包含了对Django框架精彩的讲解,有兴趣的读者可以自行购买阅读。 +> **说明**:本文的部分插图来自于《Python项目开发实战》和《精通Django》,这两本书中都包含了对Django框架精彩的讲解,有兴趣的读者可以自行购买阅读。 ### Web应用 @@ -8,9 +8,7 @@ ![](./res/web-application.png) -问题2:描述项目的物理架构。(上图中补充负载均衡(反向代理)服务器、数据库服务器、文件服务器、邮件服务器、缓存服务器、防火墙等,而且每个节点都有可能是多节点构成的集群,如下图所示,架构并不是一开始就是这样,而是逐步演进的) - -![](./res/05.django_massive_cluster.png) +问题2:描述项目的物理架构。(上图中补充负载均衡(反向代理)服务器、数据库服务器、文件服务器、邮件服务器、缓存服务器、防火墙等,而且每个节点都有可能是多节点构成的集群。当然,架构都是根据业务的需要一步步演进而不是一蹴而就的。) 问题3:描述Django项目的工作流程。(如下图所示) @@ -160,23 +158,14 @@ python manage.py inspectdb > /models.py - `filter()` / `exclude()` - `exact` / `iexact`:精确匹配/忽略大小写的精确匹配查询 - - `contains` / `icontains` / `startswith / istartswith / endswith / iendswith`:基于`like`的模糊查询 - - `in`:集合运算 - - `gt` / `gte` / `lt` / `lte`:大于/大于等于/小于/小于等于关系运算 - - `range`:指定范围查询(SQL中的`between…and…`) - - `year` / `month` / `day` / `week_day` / `hour` / `minute` / `second`:查询时间日期 - - `isnull`:查询空值(`True`)或非空值(`False`) - - `search`:基于全文索引的全文检索 - - `regex` / `iregex`:基于正则表达式的模糊匹配查询 - - `aggregate()` / `annotate()` - `Avg` / `Count` / `Sum` / `Max` / `Min` @@ -268,9 +257,9 @@ python manage.py inspectdb > /models.py #### 如何设计视图函数 -1. 用户的每个操作(用户故事)对应一个视图函数。 +1. 用户的每个请求(用户故事)对应一个视图函数,当然也可以将用户要执行的业务逻辑封装到独立的函数中,也就是有专门的模块处理程序中的业务逻辑。 -2. [每个视图函数可以构成一个事务边界](https://docs.djangoproject.com/en/2.1/ref/settings/)。 +2. 用户的请求可能会包含多个(持久化)操作,这些操作有可能需要设计成不可分割的原子性操作,那么这里就形成了事务的边界。 - 事务的ACID特性。 @@ -356,7 +345,7 @@ python manage.py inspectdb > /models.py 4. 如果使用`url`函数捕获的路径参数都是字符串,`path`函数可以指定路径参数类型。 -5. 可以使用`include`函数引入其他URL配置,捕获的参数会向下传递。 +5. 可以使用`include`函数引入其他URL配置并指定`namespace`来解决命名冲突,捕获的参数会向下传递。 6. 在`url`和`path`函数甚至是`include`函数中都可以用字典向视图传入额外的参数,如果参数与捕获的参数同名,则使用字典中的参数。 @@ -488,7 +477,9 @@ python manage.py inspectdb > /models.py - 向浏览器传输二进制数据。 ```Python - buffer = ByteIO() + from io import BytesIO + + buffer = BytesIO() resp = HttpResponse(content_type='...') resp['Content-Disposition'] = 'attachment; filename="..."' @@ -496,13 +487,16 @@ python manage.py inspectdb > /models.py ``` ```Python + from io import BytesIO + + import xlwt + + def get_style(name, color=0, bold=False, italic=False): - style = xlwt.XFStyle() font = xlwt.Font() - font.name = name - font.colour_index = color - font.bold = bold - font.italic = italic + font.name, font.colour_index, font.bold, font.italic = \ + name, color, bold, italic + style = xlwt.XFStyle() style.font = font return style @@ -535,7 +529,6 @@ python manage.py inspectdb > /models.py # 如果文件名有中文需要处理成百分号编码 resp['content-disposition'] = 'attachment; filename="detail.xls"' return resp - ``` - 大文件的流式处理:`StreamingHttpResponse`。 @@ -667,7 +660,7 @@ def simple_middleware(get_response): ``` ```Python -class MyMiddleware(object): +class MyMiddleware: def __init__(self, get_response): self.get_response = get_response @@ -680,7 +673,7 @@ class MyMiddleware(object): ``` ```Python -class MyMiddleware(object): +class MyMiddleware(MiddlewareMixin): def __init__(self): pass @@ -858,7 +851,7 @@ CACHES = { 'CONNECTION_POOL_KWARGS': { 'max_connections': 1000, }, - 'PASSWORD': '1qaz2wsx', + 'PASSWORD': 'yourpass', } }, # 页面缓存 @@ -873,7 +866,7 @@ CACHES = { 'CONNECTION_POOL_KWARGS': { 'max_connections': 500, }, - 'PASSWORD': '1qaz2wsx', + 'PASSWORD': 'yourpass', } }, # 会话缓存 @@ -889,7 +882,7 @@ CACHES = { 'CONNECTION_POOL_KWARGS': { 'max_connections': 2000, }, - 'PASSWORD': '1qaz2wsx', + 'PASSWORD': 'yourpass', } }, # 接口数据缓存 @@ -904,7 +897,7 @@ CACHES = { 'CONNECTION_POOL_KWARGS': { 'max_connections': 500, }, - 'PASSWORD': '1qaz2wsx', + 'PASSWORD': 'yourpass', } }, } @@ -986,7 +979,7 @@ urlpatterns = [ #### 日志级别 -NOTSET < DEBUG < INFO < WARNING < ERROR < FATAL +NOTSET < DEBUG < INFO < WARNING < ERROR < CRITICAL #### 日志配置 @@ -1089,13 +1082,13 @@ LOGGING = { #### 使用djangorestframework -安装djangorestfrmework(为了描述方便,以下统一简称为drf)。 +安装djangorestfrmework(为了描述方便,以下统一简称为DRF)。 ```Shell pip install djangorestframework ``` -配置drf。 +配置DRF。 ```Python INSTALLED_APPS = [ @@ -1412,7 +1405,7 @@ class HouseInfoViewSet(CacheResponseMixin, ReadOnlyModelViewSet): #### 身份认证 -查看drf中APIView类的代码可以看出,drf默认的认证方案是 `DEFAULT_AUTHENTICATION_CLASSES`,如果修改authentication_classes就可以自行定制身份认证的方案。 +查看DRF中APIView类的代码可以看出,DRF默认的认证方案是 `DEFAULT_AUTHENTICATION_CLASSES`,如果修改authentication_classes就可以自行定制身份认证的方案。 ```Python class APIView(View): @@ -1499,7 +1492,7 @@ class EstateViewSet(CacheResponseMixin, ModelViewSet): #### 授予权限 -权限检查总是在视图的最开始处运行,在任何其他代码被允许进行之前。最简单的权限是允许通过身份验证的用户访问,并拒绝未经身份验证的用户访问,这对应于dfr中的`IsAuthenticated`类,可以用它来取代默认的`AllowAny`类。权限策略可以在Django的drf配置中用`DEFAULT_PERMISSION_CLASSES`全局设置。 +权限检查总是在视图的最开始处运行,在任何其他代码被允许进行之前。最简单的权限是允许通过身份验证的用户访问,并拒绝未经身份验证的用户访问,这对应于dfr中的`IsAuthenticated`类,可以用它来取代默认的`AllowAny`类。权限策略可以在Django的DRF配置中用`DEFAULT_PERMISSION_CLASSES`全局设置。 ```Python REST_FRAMEWORK = { @@ -1579,7 +1572,7 @@ class BlacklistPermission(permissions.BasePermission): ![](./res/rbac-full.png) -2. ACL - 访问控制列表(每个用户绑定自己的访问白名单)。 +2. ACL - 访问控制列表(每个用户绑定自己的访问白名单或黑名单)。 #### 访问限流 @@ -1621,7 +1614,7 @@ def example_view(request, format=None): # 此处省略下面的代码 ``` -当然也可以通过继承`BaseThrottle`来自定义限流策略,通常需要重写`allow_request`和`wait`方法。 +当然也可以通过继承`SimpleRateThrottle`来自定义限流策略,通常需要重写`allow_request`和`wait`方法。 ### 异步任务和计划任务 @@ -1656,23 +1649,23 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis ```Python # 注册环境变量 - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fangtx.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', '项目名.settings') # 创建Celery实例 app = celery.Celery( 'fangtx', - broker='amqp://luohao:123456@120.77.222.217:5672/vhost1' + broker='amqp://luohao:123456@1.2.3.4:5672/vhost1' ) # 从项目的配置文件读取Celery配置信息 - app.config_from_object('django.conf:settings') + # app.config_from_object('django.conf:settings') # 从指定的文件(例如celery_config.py)中读取Celery配置信息 # app.config_from_object('celery_config') # 让Celery自动从参数指定的应用中发现异步任务/定时任务 - app.autodiscover_tasks(['common', ]) + # app.autodiscover_tasks(['common', ]) # 让Celery自动从所有注册的应用中发现异步任务/定时任务 - # app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) + app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) ``` 4. 启动Celery创建woker(消息的消费者)。 @@ -1685,10 +1678,11 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis ```Python @app.task - def send_email(from, to, cc, subject, content): + def send_email(from_user, to_user, cc_user, subject, content): pass + # 消息的生产者 send_email.delay('', [], [], '', '') ``` @@ -1704,9 +1698,9 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis # 将来实际部署项目的时候生产者、消费者、消息队列可能都是不同节点 beat_schedule={ 'task1': { - 'task': 'common.tasks.show_msg', - 'schedule': crontab(), - 'args': ('刘强东,奶茶妹妹喊你回家喝奶啦', ) + 'task': 'common.tasks.scheduled_task', + 'schedule': crontab('*', '*', '*', '*', '*'), + 'args': ('...', ) }, }, ) @@ -1714,8 +1708,8 @@ Celery是一个本身不提供队列服务,官方推荐使用RabbitMQ或Redis ```Python @app.task - def show_msg(content): - print(content) + def scheduled_task(*args, **kwargs): + pass ``` 7. 启动Celery创建执行定时任务的beat(消息的生产者)。 @@ -1764,13 +1758,13 @@ CORS_ORIGIN_ALLOW_ALL = True ### 安全保护 -问题1:什么是跨站脚本攻击,如何防范?(对提交的内容进行消毒) +问题1:什么是跨站脚本攻击(XSS),如何防范?(对提交的内容进行消毒) -问题2:什么是跨站身份伪造,如何防范?(使用随机令牌) +问题2:什么是跨站身份伪造(CSRF),如何防范?(使用随机令牌) -问题3:什么是SQL注射攻击,如何防范?(不拼接SQL语句,避免使用单引号) +问题3:什么是SQL注射攻击(SQL Injection),如何防范?(不拼接SQL语句,避免使用单引号) -问题4:什么是点击劫持攻击,如何防范?(不允许`