2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -4,7 +4,7 @@
`class` 定义如下:
```
```py
class ClassName(ParentClass):
"""class docstring"""
def method(self):
@@ -22,7 +22,7 @@ class ClassName(ParentClass):
In [1]:
```
```py
class Forest(object):
""" Forest can grow trees which eventually die."""
pass
@@ -35,13 +35,13 @@ class Forest(object):
In [2]:
```
```py
import numpy as np
np.info(Forest)
```
```
```py
Forest()
Forest can grow trees which eventually die.
@@ -52,21 +52,21 @@ Methods:
In [3]:
```
```py
forest = Forest()
```
In [4]:
```
```py
forest
```
Out[4]:
```
```py
<__main__.Forest at 0x3cda358>
```
@@ -76,21 +76,21 @@ Out[4]:
In [5]:
```
```py
forest.trees = np.zeros((150, 150), dtype=bool)
```
In [6]:
```
```py
forest.trees
```
Out[6]:
```
```py
array([[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
@@ -102,7 +102,7 @@ array([[False, False, False, ..., False, False, False],
In [7]:
```
```py
forest2 = Forest()
```
@@ -111,12 +111,12 @@ forest2 = Forest()
In [8]:
```
```py
forest2.trees
```
```
```py
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-42e6a9d57a8b> in <module>()
@@ -129,7 +129,7 @@ AttributeError: 'Forest' object has no attribute 'trees'
In [9]:
```
```py
class Forest(object):
""" Forest can grow trees which eventually die."""
def grow(self):
@@ -145,7 +145,7 @@ class Forest(object):
In [10]:
```
```py
forest = Forest()
forest.grow()
@@ -153,7 +153,7 @@ forest.number(12)
```
```
```py
the tree is growing!
there are 12 trees.