|
二楼正解,learning python里面有提及。
- Don’t expect results from functions that change objects in place. We encountered
- this one earlier, too: in-place change operations like the list.append and
- list.sort methods introduced in Chapter 8 do not return values (other than
- None), so you should call them without assigning the result. It’s not uncommon for
- beginners to say something like mylist = mylist.append(X) to try to get the result
- of an append, but what this actually does is assign mylist to None, not to the modified
- list (in fact, you’ll lose your reference to the list altogether).
复制代码 |
|