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.
2 parents 78f6f4c + 6a9cd29 commit f0769f4Copy full SHA for f0769f4
README.md
@@ -81,19 +81,19 @@ True
81
调用对象的 \__repr__ 方法,获得该方法的返回值,如下例子返回值为字符串
82
83
```python
84
-In [1]: class Student():
85
- ...: def __init__(self,id,name):
86
- ...: self.id = id
87
- ...: self.name = name
88
- ...: def __repr__(self):
89
- ...: return 'id = '+self.id +', name = '+self.name
90
- ...:
91
+class Student():
+ def __init__(self,id,name):
+ self.id = id
+ self.name = name
+ def __repr__(self):
+ return 'id = '+self.id +', name = '+self.name
+```
92
93
-In [2]: xiaoming = Student(id='001',name='xiaoming')
+```python
+In [2]: xiaoming = Student(id='1',name='xiaoming')
94
95
In [3]: print(xiaoming)
96
-id = 001, name = xiaoming
+id = 1, name = xiaoming
97
98
In [4]: ascii(xiaoming)
99
Out[4]: 'id = 001, name = xiaoming'
0 commit comments