This commit is contained in:
yinkanglong_lab
2021-03-19 23:27:00 +08:00
parent 9cd1fe4b4f
commit f73f47e46e
38 changed files with 123 additions and 569 deletions

View File

@@ -8,50 +8,14 @@ NumPy 数组的维数称为秩rank秩就是轴的数量即数组的
* 第一维是高维,最后一维是低维。
## 数组属性
<table class="reference">
<thead>
<tr class="header">
<th>属性</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>ndarray.ndim</td>
<td>秩,即轴的数量或维度的数量</td>
</tr>
<tr>
<td>ndarray.shape</td>
<td>数组的维度对于矩阵n 行 m 列</td>
</tr>
<tr>
<td>ndarray.size</td>
<td>数组元素的总个数,相当于 .shape 中 n*m 的值</td>
</tr>
<tr>
<td>ndarray.dtype</td>
<td>ndarray 对象的元素类型</td>
</tr>
<tr>
<td>ndarray.itemsize</td>
<td>ndarray 对象中每个元素的大小,以字节为单位</td>
</tr>
<tr>
<td>ndarray.flags</td>
<td>ndarray 对象的内存信息</td>
</tr>
<tr>
<td>ndarray.real</td>
<td>ndarray元素的实部</td>
</tr>
<tr>
<td>ndarray.imag</td>
<td>ndarray 元素的虚部</td>
</tr>
<tr>
<td>ndarray.data</td>
<td>包含实际数组元素的缓冲区,由于一般通过数组的索引获取元素,所以通常不需要使用这个属性。</td>
</tr>
</tbody>
</table>
| 属性 | 说明 |
|------------------|---------------------------------------------|
| `ndarray.ndim` | 秩,即轴的数量或维度的数量 |
| `ndarray.shape` | 数组的维度对于矩阵n 行 m 列 |
| `ndarray.size` | 数组元素的总个数,相当于 .shape 中 n*m 的值 |
| `ndarray.dtype` | ndarray 对象的元素类型 |
| `ndarray.itemsize` | ndarray 对象中每个元素的大小,以字节为单位 |
| `ndarray.flags` | ndarray 对象的内存信息 |
| `ndarray.real` | ndarray元素的实部 |
| `ndarray.imag` | ndarray 元素的虚部 |
| `ndarray.data` | 包含实际数组元素的缓冲区,由于一般通过数组的索引获取元素,所以通常不需要使用这个属性。 |

View File

@@ -0,0 +1,26 @@
## 程序设计的基础知识
* 程序的定义:为了完成某项任务解决某个问题,计算机及执行的一定的指令
* 计算机:实现程序的机器,Enia宾夕法尼亚大学-电子管-晶体管-集成电路
* cup构成冯诺依曼的计算机结构输入设备-存储器-输出设备-控制器-计算器
## 人与机器的沟通
* 程序设计语言:汇编语言-低级语言-高级语言python-Java
* 分类编译型语言source code -compiler- object
CODe。解释性语言sourcecode-interpreter-output
* 创始人:吉多·范·罗苏姆蟒蛇
* python解释性语言可移植性强执行效率低设计哲学优雅明确简单
## 第一个程序hello world
* print python
* 命令行Linux系统下)优点:无需创建文件,立即看到裕运行的结果
* 脚本IDE编辑器适合编写大型程序更容易纠错更容易修改和执行

View File

@@ -1,57 +1,56 @@
\>选择结构
\>\>程序流程图:用简单的图形表示问题的解决步骤;起止框,处理匡,判断框,文档框,流程线,圆形,输入输出框
## 选择结构
\>\>语法python中大括号不是分区作用是靠语句块的缩进来体现语句块术语的范围
* 程序流程图:用简单的图形表示问题的解决步骤;起止框,处理匡,判断框,文档框,流程线,圆形,输入输出框
* 语法python中大括号不是分区作用是靠语句块的缩进来体现语句块术语的范围
```
if 条件:
缩进语句块
缩进语句块
其余的语句
if 条件:
缩进语句块
缩进语句块
else
缩进语句块
缩进语句块
```
\>\>if语句支持嵌套
* if语句支持嵌套
\>\>多分支结构elif 条件==else if
* 多分支结构elif 条件==else if
条件,有助于简化缩进,是画面更加清晰,可读性更高
涉及到两个典型的例子elif计算多分支结构领先是否安全的例子
\>循环结构
\>\>while条件判断成立则执行循环体不成立则不执行
## 循环结构
* while条件判断成立则执行循环体不成立则不执行
```
初始化语句
while 条件语句:
循环体
循环体
其它语句
```
* break结束当前循环体
\>\>break结束当前循环
\>\>continue结束这次循环或者说开始新的循环
\>\>for循环
* continue结束这次循环或者说开始新的循环
* for循环
```
for element in object
循环体
循环体
```
\>\>range(startstopstep)生成连续整数
\>\>穷举法的使用-鸡兔同笼问题
\>\>循环的嵌套问题
* range(startstopstep)生成连续整数
\>程序控制结构的练习题

View File

@@ -1,26 +0,0 @@
**\>程序设计的基础知识**
\>\>程序的定义:为了完成某项任务解决某个问题,计算机及执行的一定的指令
\>\>计算机:实现程序的机器,Enia宾夕法尼亚大学-电子管-晶体管-集成电路
\>\>cup构成冯诺依曼的计算机结构输入设备-存储器-输出设备-控制器-计算器
**\>人与机器的沟通**
\>\>程序设计语言:汇编语言-低级语言-高级语言python-Java
\>\>分类编译型语言source code -compiler- object
CODe。解释性语言sourcecode-interpreter-output
\>\>创始人:吉多·范·罗苏姆蟒蛇
\>\>python解释性语言可移植性强执行效率低设计哲学优雅明确简单
**\>第一个程序hello world**
\>\>print python
\>\>命令行Linux系统下)优点:无需创建文件,立即看到裕运行的结果
脚本IDE编辑器适合编写大型程序更容易纠错更容易修改和执行

View File

@@ -1,103 +0,0 @@
\>递归的实现:
**[python]** [view
plain](http://blog.csdn.net/estom_yin/article/details/51892697)
[copy](http://blog.csdn.net/estom_yin/article/details/51892697)
1. \<pre name="code" **class**="python"\>**def** p(n):
2. **if** n ==1 **or** n == 0:
3. **return** 1
\>递归的设计:
> 将问题分解成许多同构的问题,然后以相同的方式解决最终分解的小问题。
> 递归的要素:
> 递归执行的操作
> 递归的结束条件
> 递归的参数传递
\>实例一:兔子序列(菲波那切数列,在自然界一些动植物身上都有体现)
**[python]** [view
plain](http://blog.csdn.net/estom_yin/article/details/51892697)
[copy](http://blog.csdn.net/estom_yin/article/details/51892697)
1. **def** fib(n):
2. **if** n == 1 **or** n == 2:
3. **return** 1
4. **else**:
5. **return** fib(n - 1) + fib(n - 2)
6. **print** fib(20)
\>实例二:汉诺塔问题
**[python]** [view
plain](http://blog.csdn.net/estom_yin/article/details/51892697)
[copy](http://blog.csdn.net/estom_yin/article/details/51892697)
1. **def** hanoi(n, A, B, C):
2. **if** n == 1:
3. **print** "move", n, "from", A, "to", C
4. **else**:
5. hanoi(n - 1, A, C, B)
6. **print** 'move', n, 'from', A, 'to', C
7. hanoi(n - 1, B, A, C)
8.
9. hanoi(10, 'left', 'Mid', 'Right')
\>实例三:停车问题
> 要求:在固定长度的马路上随机停车,根据车身长度以及随机性特点确定,马路长度与停车数量的关系
**[python]** [view
plain](http://blog.csdn.net/estom_yin/article/details/51892697)
[copy](http://blog.csdn.net/estom_yin/article/details/51892697)
1. **import** random
2. \#if the w big enough, lim parking to 3.7472 named Reni constance
3.
4. **def** parking(low, high):
5. **if** high - low \< 1:
6. **return** 0
7. **else**:
8. x = random.uniform(low, high - 1)
9. **return** parking(low, x) + 1 + parking(x + 1, high)
10. **print** parking(0, 5)
\>递归的优劣
\>\>能使一个蕴含递归关系而且结构复杂的程序简洁精练,增强可读性
\>\>嵌套层次深,函数调用开销大,存在大量的重复计算
\>补充琐碎知识
> random.uniform(low, high) 能产生从low到high的随机数

View File

@@ -4,5 +4,6 @@
> python3中所有的数据类型都是对象。包括数值类型int,float,complex)、列表、字典、元组、集合等。包括函数也是对象。
> python3中所有的内建类的对象不具有动态属性。所有的自定义类的对象都有动态属性。

View File

@@ -136,7 +136,7 @@ Python 具有不同的运算符,可让您在程序中执行所需的计算。
在上面的表达式中,将对哪个运算进行第一个加法或乘法运算? 为了回答这样的问题,我们需要在 python 中引用运算符优先级列表。 下图列出了 python 优先级从高到低的顺序。
![python-operator-precedence1.jpg](img/1bd07b9ee86ea977adf3c113fe0e0939.png)
![](image/2021-03-19-21-44-53.png)
如您在上表中所见`*`在`+`之上,因此`*`将首先出现,然后加法。 因此,以上表达式的结果将为`13`。
@@ -150,7 +150,6 @@ Python 具有不同的运算符,可让您在程序中执行所需的计算。
```py
>>> 3 + 4 - 2
```
在以上表达式中,将首先进行加法或减法。 从表`+`和`-`的优先级相同,然后将它们从左到右进行求值,即先加法,然后减法。
@@ -209,8 +208,8 @@ a = b = c
| `+=` | 加法赋值 | `x += 4` | `x = x + 4` |
| `-=` | 减法赋值 | `x -= 2` | `x = x - 2` |
| `*=` | 乘法赋值 | `x *= 5` | `x = x * 5` |
| `/*=` | 除法赋值 | `x /= 5` | `x = x / 5` |
| `//*=` | 整数除法赋值 | `x //= 5` | `x = x // 5` |
| `%*=` | 余数赋值 | `x %= 5` | `x = x % 5` |
| `/=` | 除法赋值 | `x /= 5` | `x = x / 5` |
| `//=` | 整数除法赋值 | `x //= 5` | `x = x // 5` |
| `%=` | 余数赋值 | `x %= 5` | `x = x % 5` |
| `**=` | 指数赋值 | `x **= 5` | `x = x ** 5` |

View File

@@ -5,7 +5,7 @@
* 元组
* 集合
## 5.6. 循环的技巧
## 5.6. 循环的技巧
* 当在字典中循环时,用 items() 方法可将关键字和对应的值同时取出
```py
>>>

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -1,244 +1,17 @@
## 内置函数列表
<table class="docutils align-default">
<colgroup>
<col style="width: 21%">
<col style="width: 18%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 22%">
</colgroup>
<thead>
<tr class="row-odd"><th class="head"></th>
<th class="head"></th>
<th class="head"><p>内置函数</p></th>
<th class="head"></th>
<th class="head"></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><a class="reference internal" href="#abs" title="abs"><code class="xref py py-func docutils literal notranslate"><span class="pre">abs()</span></code></a></p></td>
<td><p><a class="reference internal" href="#delattr" title="delattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">delattr()</span></code></a></p></td>
<td><p><a class="reference internal" href="#hash" title="hash"><code class="xref py py-func docutils literal notranslate"><span class="pre">hash()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-memoryview"><code class="docutils literal notranslate"><span class="pre">memoryview()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-set"><code class="docutils literal notranslate"><span class="pre">set()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#all" title="all"><code class="xref py py-func docutils literal notranslate"><span class="pre">all()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-dict"><code class="docutils literal notranslate"><span class="pre">dict()</span></code></a></p></td>
<td><p><a class="reference internal" href="#help" title="help"><code class="xref py py-func docutils literal notranslate"><span class="pre">help()</span></code></a></p></td>
<td><p><a class="reference internal" href="#min" title="min"><code class="xref py py-func docutils literal notranslate"><span class="pre">min()</span></code></a></p></td>
<td><p><a class="reference internal" href="#setattr" title="setattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">setattr()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#any" title="any"><code class="xref py py-func docutils literal notranslate"><span class="pre">any()</span></code></a></p></td>
<td><p><a class="reference internal" href="#dir" title="dir"><code class="xref py py-func docutils literal notranslate"><span class="pre">dir()</span></code></a></p></td>
<td><p><a class="reference internal" href="#hex" title="hex"><code class="xref py py-func docutils literal notranslate"><span class="pre">hex()</span></code></a></p></td>
<td><p><a class="reference internal" href="#next" title="next"><code class="xref py py-func docutils literal notranslate"><span class="pre">next()</span></code></a></p></td>
<td><p><a class="reference internal" href="#slice" title="slice"><code class="xref py py-func docutils literal notranslate"><span class="pre">slice()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#ascii" title="ascii"><code class="xref py py-func docutils literal notranslate"><span class="pre">ascii()</span></code></a></p></td>
<td><p><a class="reference internal" href="#divmod" title="divmod"><code class="xref py py-func docutils literal notranslate"><span class="pre">divmod()</span></code></a></p></td>
<td><p><a class="reference internal" href="#id" title="id"><code class="xref py py-func docutils literal notranslate"><span class="pre">id()</span></code></a></p></td>
<td><p><a class="reference internal" href="#object" title="object"><code class="xref py py-func docutils literal notranslate"><span class="pre">object()</span></code></a></p></td>
<td><p><a class="reference internal" href="#sorted" title="sorted"><code class="xref py py-func docutils literal notranslate"><span class="pre">sorted()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#bin" title="bin"><code class="xref py py-func docutils literal notranslate"><span class="pre">bin()</span></code></a></p></td>
<td><p><a class="reference internal" href="#enumerate" title="enumerate"><code class="xref py py-func docutils literal notranslate"><span class="pre">enumerate()</span></code></a></p></td>
<td><p><a class="reference internal" href="#input" title="input"><code class="xref py py-func docutils literal notranslate"><span class="pre">input()</span></code></a></p></td>
<td><p><a class="reference internal" href="#oct" title="oct"><code class="xref py py-func docutils literal notranslate"><span class="pre">oct()</span></code></a></p></td>
<td><p><a class="reference internal" href="#staticmethod" title="staticmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">staticmethod()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#bool" title="bool"><code class="xref py py-func docutils literal notranslate"><span class="pre">bool()</span></code></a></p></td>
<td><p><a class="reference internal" href="#eval" title="eval"><code class="xref py py-func docutils literal notranslate"><span class="pre">eval()</span></code></a></p></td>
<td><p><a class="reference internal" href="#int" title="int"><code class="xref py py-func docutils literal notranslate"><span class="pre">int()</span></code></a></p></td>
<td><p><a class="reference internal" href="#open" title="open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-str"><code class="docutils literal notranslate"><span class="pre">str()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#breakpoint" title="breakpoint"><code class="xref py py-func docutils literal notranslate"><span class="pre">breakpoint()</span></code></a></p></td>
<td><p><a class="reference internal" href="#exec" title="exec"><code class="xref py py-func docutils literal notranslate"><span class="pre">exec()</span></code></a></p></td>
<td><p><a class="reference internal" href="#isinstance" title="isinstance"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a></p></td>
<td><p><a class="reference internal" href="#ord" title="ord"><code class="xref py py-func docutils literal notranslate"><span class="pre">ord()</span></code></a></p></td>
<td><p><a class="reference internal" href="#sum" title="sum"><code class="xref py py-func docutils literal notranslate"><span class="pre">sum()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#func-bytearray"><code class="docutils literal notranslate"><span class="pre">bytearray()</span></code></a></p></td>
<td><p><a class="reference internal" href="#filter" title="filter"><code class="xref py py-func docutils literal notranslate"><span class="pre">filter()</span></code></a></p></td>
<td><p><a class="reference internal" href="#issubclass" title="issubclass"><code class="xref py py-func docutils literal notranslate"><span class="pre">issubclass()</span></code></a></p></td>
<td><p><a class="reference internal" href="#pow" title="pow"><code class="xref py py-func docutils literal notranslate"><span class="pre">pow()</span></code></a></p></td>
<td><p><a class="reference internal" href="#super" title="super"><code class="xref py py-func docutils literal notranslate"><span class="pre">super()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#func-bytes"><code class="docutils literal notranslate"><span class="pre">bytes()</span></code></a></p></td>
<td><p><a class="reference internal" href="#float" title="float"><code class="xref py py-func docutils literal notranslate"><span class="pre">float()</span></code></a></p></td>
<td><p><a class="reference internal" href="#iter" title="iter"><code class="xref py py-func docutils literal notranslate"><span class="pre">iter()</span></code></a></p></td>
<td><p><a class="reference internal" href="#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-tuple"><code class="docutils literal notranslate"><span class="pre">tuple()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#callable" title="callable"><code class="xref py py-func docutils literal notranslate"><span class="pre">callable()</span></code></a></p></td>
<td><p><a class="reference internal" href="#format" title="format"><code class="xref py py-func docutils literal notranslate"><span class="pre">format()</span></code></a></p></td>
<td><p><a class="reference internal" href="#len" title="len"><code class="xref py py-func docutils literal notranslate"><span class="pre">len()</span></code></a></p></td>
<td><p><a class="reference internal" href="#property" title="property"><code class="xref py py-func docutils literal notranslate"><span class="pre">property()</span></code></a></p></td>
<td><p><a class="reference internal" href="#type" title="type"><code class="xref py py-func docutils literal notranslate"><span class="pre">type()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#chr" title="chr"><code class="xref py py-func docutils literal notranslate"><span class="pre">chr()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-frozenset"><code class="docutils literal notranslate"><span class="pre">frozenset()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-list"><code class="docutils literal notranslate"><span class="pre">list()</span></code></a></p></td>
<td><p><a class="reference internal" href="#func-range"><code class="docutils literal notranslate"><span class="pre">range()</span></code></a></p></td>
<td><p><a class="reference internal" href="#vars" title="vars"><code class="xref py py-func docutils literal notranslate"><span class="pre">vars()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#classmethod" title="classmethod"><code class="xref py py-func docutils literal notranslate"><span class="pre">classmethod()</span></code></a></p></td>
<td><p><a class="reference internal" href="#getattr" title="getattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">getattr()</span></code></a></p></td>
<td><p><a class="reference internal" href="#locals" title="locals"><code class="xref py py-func docutils literal notranslate"><span class="pre">locals()</span></code></a></p></td>
<td><p><a class="reference internal" href="#repr" title="repr"><code class="xref py py-func docutils literal notranslate"><span class="pre">repr()</span></code></a></p></td>
<td><p><a class="reference internal" href="#zip" title="zip"><code class="xref py py-func docutils literal notranslate"><span class="pre">zip()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#compile" title="compile"><code class="xref py py-func docutils literal notranslate"><span class="pre">compile()</span></code></a></p></td>
<td><p><a class="reference internal" href="#globals" title="globals"><code class="xref py py-func docutils literal notranslate"><span class="pre">globals()</span></code></a></p></td>
<td><p><a class="reference internal" href="#map" title="map"><code class="xref py py-func docutils literal notranslate"><span class="pre">map()</span></code></a></p></td>
<td><p><a class="reference internal" href="#reversed" title="reversed"><code class="xref py py-func docutils literal notranslate"><span class="pre">reversed()</span></code></a></p></td>
<td><p><a class="reference internal" href="#__import__" title="__import__"><code class="xref py py-func docutils literal notranslate"><span class="pre">__import__()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#complex" title="complex"><code class="xref py py-func docutils literal notranslate"><span class="pre">complex()</span></code></a></p></td>
<td><p><a class="reference internal" href="#hasattr" title="hasattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">hasattr()</span></code></a></p></td>
<td><p><a class="reference internal" href="#max" title="max"><code class="xref py py-func docutils literal notranslate"><span class="pre">max()</span></code></a></p></td>
<td><p><a class="reference internal" href="#round" title="round"><code class="xref py py-func docutils literal notranslate"><span class="pre">round()</span></code></a></p></td>
<td></td>
</tr>
</tbody>
</table>
abs()
delattr()
hash()
memoryview()
set()
all()
dict()
help()
min()
setattr()
any()
dir()
hex()
next()
slice()
ascii()
divmod()
id()
object()
sorted()
bin()
enumerate()
input()
oct()
staticmethod()
bool()
eval()
int()
open()
str()
breakpoint()
exec()
isinstance()
ord()
sum()
bytearray()
filter()
issubclass()
pow()
super()
bytes()
float()
iter()
print()
tuple()
callable()
format()
len()
property()
type()
chr()
frozenset()
list()
range()
vars()
classmethod()
getattr()
locals()
repr()
zip()
compile()
globals()
map()
reversed()
__import__()
complex()
hasattr()
max()
round()
| | | 内置函数 | | |
|---------------|-------------|--------------|--------------|----------------|
| abs() | delattr() | hash() | memoryview() | set() |
| all() | dict() | help() | min() | setattr() |
| any() | dir() | hex() | next() | slice() |
| ascii() | divmod() | id() | object() | sorted() |
| bin() | enumerate() | input() | oct() | staticmethod() |
| bool() | eval() | int() | open() | str() |
| breakpoint() | exec() | isinstance() | ord() | sum() |
| bytearray() | filter() | issubclass() | pow() | super() |
| bytes() | float() | iter() | print() | tuple() |
| callable() | format() | len() | property() | type() |
| chr() | frozenset() | list() | range() | vars() |
| classmethod() | getattr() | locals() | repr() | zip() |
| compile() | globals() | map() | reversed() | \_\_import\_\_() |
| complex() | hasattr() | max() | round() | |

View File

@@ -1,5 +1,5 @@
## 内置常量
### False
### `False`
bool 类型的假值。 给 False 赋值是非法的并会引发 SyntaxError。
### `True`

View File

@@ -1,22 +1,22 @@
## datetime
有效的类型
class datetime.date
### `class datetime.date`
一个理想化的简单型日期,它假设当今的公历在过去和未来永远有效。 属性: year, month, and day。
class datetime.time
### `class datetime.time`
一个独立于任何特定日期的理想化时间,它假设每一天都恰好等于 24*60*60 秒。 (这里没有“闰秒”的概念。) 包含属性: hour, minute, second, microsecond 和 tzinfo。
class datetime.datetime
### `class datetime.datetime`
日期和时间的结合。属性year, month, day, hour, minute, second, microsecond, and tzinfo.
class datetime.timedelta
### `class datetime.timedelta`
表示两个 date 对象或者 time 对象,或者 datetime 对象之间的时间间隔,精确到微秒。
class datetime.tzinfo
### `class datetime.tzinfo`
一个描述时区信息对象的抽象基类。 用来给 datetime 和 time 类提供自定义的时间调整概念(例如处理时区和/或夏令时)。
class datetime.timezone
### `class datetime.timezone`
一个实现了 tzinfo 抽象基类的子类,用于表示相对于 世界标准时间UTC的偏移量。
@@ -26,49 +26,24 @@ class datetime.timezone
### `class calendar.TextCalendar(firstweekday=0)`
### `class calendar.HTMLCalendar(firstweekday=0)`
### `class calendar.LocaleTextCalendar(firstweekday=0, locale=None)`
### `class calendar.LocaleHTMLCalendar(firstweekday=0, locale=None)```
### `class calendar.LocaleHTMLCalendar(firstweekday=0, locale=None)`
## collections --- 容器数据类型
这个模块实现了特定目标的容器以提供Python标准内建容器 dict , list , set , 和 tuple 的替代选择。
<table class="docutils align-default">
<colgroup>
<col style="width: 24%">
<col style="width: 76%">
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a></p></td>
<td><p>创建命名元组子类的工厂函数</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#collections.deque" title="collections.deque"><code class="xref py py-class docutils literal notranslate"><span class="pre">deque</span></code></a></p></td>
<td><p>类似列表(list)的容器,实现了在两端快速添加(append)和弹出(pop)</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#collections.ChainMap" title="collections.ChainMap"><code class="xref py py-class docutils literal notranslate"><span class="pre">ChainMap</span></code></a></p></td>
<td><p>类似字典(dict)的容器类,将多个映射集合到一个视图里面</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#collections.Counter" title="collections.Counter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Counter</span></code></a></p></td>
<td><p>字典的子类,提供了可哈希对象的计数功能</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#collections.OrderedDict" title="collections.OrderedDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">OrderedDict</span></code></a></p></td>
<td><p>字典的子类,保存了他们被添加的顺序</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#collections.defaultdict" title="collections.defaultdict"><code class="xref py py-class docutils literal notranslate"><span class="pre">defaultdict</span></code></a></p></td>
<td><p>字典的子类,提供了一个工厂函数,为字典查询提供一个默认值</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#collections.UserDict" title="collections.UserDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserDict</span></code></a></p></td>
<td><p>封装了字典对象,简化了字典子类化</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#collections.UserList" title="collections.UserList"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserList</span></code></a></p></td>
<td><p>封装了列表对象,简化了列表子类化</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#collections.UserString" title="collections.UserString"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserString</span></code></a></p></td>
<td><p>封装了列表对象,简化了字符串子类化</p></td>
</tr>
</tbody>
</table>
| 容器| 作用|
|--------------|------------------------------------------|
| `namedtuple()` | 创建命名元组子类的工厂函数 |
| `deque` | 类似列表(list)的容器,实现了在两端快速添加(append)和弹出(pop) |
| `ChainMap` | 类似字典(dict)的容器类,将多个映射集合到一个视图里面 |
| `Counter` | 字典的子类,提供了可哈希对象的计数功能 |
| `OrderedDict` | 字典的子类,保存了他们被添加的顺序 |
| `defaultdict` | 字典的子类,提供了一个工厂函数,为字典查询提供一个默认值 |
| `UserDict` | 封装了字典对象,简化了字典子类化 |
| `UserList` | 封装了列表对象,简化了列表子类化 |
| `UserString` | 封装了列表对象,简化了字符串子类化 |
## collections.abc --- 容器的抽象基类

View File

@@ -271,46 +271,17 @@ def phi(x):
该模块提供了用于计算数字 (Real-valued) 数据的数理统计量的函数。
## 平均值以及对中心位置的评估
<table class="docutils align-default">
<colgroup>
<col style="width: 27%">
<col style="width: 73%">
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.mean" title="statistics.mean"><code class="xref py py-func docutils literal notranslate"><span class="pre">mean()</span></code></a></p></td>
<td><p>数据的算术平均数(“平均数”)。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#statistics.fmean" title="statistics.fmean"><code class="xref py py-func docutils literal notranslate"><span class="pre">fmean()</span></code></a></p></td>
<td><p>快速的,浮点算数平均数。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.geometric_mean" title="statistics.geometric_mean"><code class="xref py py-func docutils literal notranslate"><span class="pre">geometric_mean()</span></code></a></p></td>
<td><p>数据的几何平均数</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#statistics.harmonic_mean" title="statistics.harmonic_mean"><code class="xref py py-func docutils literal notranslate"><span class="pre">harmonic_mean()</span></code></a></p></td>
<td><p>数据的调和均值</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.median" title="statistics.median"><code class="xref py py-func docutils literal notranslate"><span class="pre">median()</span></code></a></p></td>
<td><p>数据的中位数(中间值)</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#statistics.median_low" title="statistics.median_low"><code class="xref py py-func docutils literal notranslate"><span class="pre">median_low()</span></code></a></p></td>
<td><p>数据的低中位数</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.median_high" title="statistics.median_high"><code class="xref py py-func docutils literal notranslate"><span class="pre">median_high()</span></code></a></p></td>
<td><p>数据的高中位数</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#statistics.median_grouped" title="statistics.median_grouped"><code class="xref py py-func docutils literal notranslate"><span class="pre">median_grouped()</span></code></a></p></td>
<td><p>分组数据的中位数即第50个百分点。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.mode" title="statistics.mode"><code class="xref py py-func docutils literal notranslate"><span class="pre">mode()</span></code></a></p></td>
<td><p>离散的或标称的数据的单个众数(出现最多的值)。</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#statistics.multimode" title="statistics.multimode"><code class="xref py py-func docutils literal notranslate"><span class="pre">multimode()</span></code></a></p></td>
<td><p>离散的或标称的数据的众数列表(出现最多的值)。</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#statistics.quantiles" title="statistics.quantiles"><code class="xref py py-func docutils literal notranslate"><span class="pre">quantiles()</span></code></a></p></td>
<td><p>将数据以相等的概率分为多个间隔。</p></td>
</tr>
</tbody>
</table>
| 函数 | 说明 |
|------------------|-------------------------|
| `mean()` | 数据的算术平均数(“平均数”)。 |
| `fmean()` | 快速的,浮点算数平均数。 |
| `geometric_mean()` | 数据的几何平均数 |
| `harmonic_mean()` | 数据的调和均值 |
| `median()` | 数据的中位数(中间值) |
| `median_low()` | 数据的低中位数 |
| `median_high()` | 数据的高中位数 |
| `median_grouped()` | 分组数据的中位数即第50个百分点。 |
| `mode()` | 离散的或标称的数据的单个众数(出现最多的值)。 |
| `multimode()` | 离散的或标称的数据的众数列表(出现最多的值)。 |
| `quantiles()` | 将数据以相等的概率分为多个间隔。 |