未验证 提交 2379ce5a 编写于 作者: X Xudong 提交者: GitHub

Update 2.2.md

directly call method getitem() will receive a NameError
we can use x.__getitem__(0) or index grammar x[0]
上级 bc68dc35
......@@ -110,9 +110,9 @@ Python 中的元组(以及多数其它编程语言中的序列)下标都以
>>> def make_rat(n, d):
return (n, d)
>>> def numer(x):
return getitem(x, 0)
return x.__getitem__(0)
>>> def denom(x):
return getitem(x, 1)
return x.__getitem__(1)
```
用于打印有理数的函数完成了我们对抽象数据结构的实现。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册