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

@@ -2,7 +2,7 @@
一个类定义的基本形式如下:
```
```py
class ClassName(ParentClass):
"""class docstring"""
def method(self):
@@ -24,7 +24,7 @@ class ClassName(ParentClass):
In [1]:
```
```py
class Leaf(object):
def __init__(self, color="green"):
self.color = color
@@ -37,26 +37,26 @@ class Leaf(object):
In [2]:
```
```py
leaf = Leaf()
print leaf.color
```
```
```py
green
```
In [3]:
```
```py
leaf.fall()
```
```
```py
Splat!
```
@@ -65,7 +65,7 @@ Splat!
In [4]:
```
```py
class MapleLeaf(Leaf):
def change_color(self):
if self.color == "green":
@@ -77,26 +77,26 @@ class MapleLeaf(Leaf):
In [5]:
```
```py
mleaf = MapleLeaf()
print mleaf.color
```
```
```py
green
```
In [6]:
```
```py
mleaf.fall()
```
```
```py
Splat!
```
@@ -105,14 +105,14 @@ Splat!
In [7]:
```
```py
mleaf.change_color()
print mleaf.color
```
```
```py
red
```
@@ -121,7 +121,7 @@ red
In [8]:
```
```py
class MapleLeaf(Leaf):
def change_color(self):
if self.color == "green":
@@ -134,7 +134,7 @@ class MapleLeaf(Leaf):
In [9]:
```
```py
mleaf = MapleLeaf()
print mleaf.color
@@ -143,7 +143,7 @@ print mleaf.color
```
```
```py
green
Plunk!
red