We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 846d238 commit 6a9cd29Copy full SHA for 6a9cd29
README.md
@@ -72,19 +72,19 @@ Out[5]: True
72
调用对象的 \__repr__ 方法,获得该方法的返回值,如下例子返回值为字符串
73
74
```python
75
-In [1]: class Student():
76
- ...: def __init__(self,id,name):
77
- ...: self.id = id
78
- ...: self.name = name
79
- ...: def __repr__(self):
80
- ...: return 'id = '+self.id +', name = '+self.name
81
- ...:
82
+class Student():
+ def __init__(self,id,name):
+ self.id = id
+ self.name = name
+ def __repr__(self):
+ return 'id = '+self.id +', name = '+self.name
+```
83
84
-In [2]: xiaoming = Student(id='001',name='xiaoming')
+```python
+In [2]: xiaoming = Student(id='1',name='xiaoming')
85
86
In [3]: print(xiaoming)
87
-id = 001, name = xiaoming
+id = 1, name = xiaoming
88
89
In [4]: ascii(xiaoming)
90
Out[4]: 'id = 001, name = xiaoming'
0 commit comments