Skip to content

Commit 75ae1a8

Browse files
committed
2019.2.13 修改 section02, dataclass 代码
1 parent 81d2236 commit 75ae1a8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

section_02_data class/dataclass01.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,18 @@ class Point:
1616

1717
p = Point(x=2, y=3)
1818
print(p)
19+
20+
21+
class Point2:
22+
def __init__(self, x, y, z=0.0):
23+
self.x = x
24+
self.y = y
25+
self.z = z
26+
27+
def __repr__(self):
28+
return 'Point(x={}, y={}, z={})'.format(self.x, self.y, self.z)
29+
30+
31+
p = Point2(1.5, 2.5)
32+
print(p)
33+
print(p.x, p.y, p.z)

0 commit comments

Comments
 (0)