求助
本帖最后由 小向阳 于 2017-3-4 19:56 编辑我的版本是python2.7,reverse()不是倒序的吗?怎么会输出None?{:5_92:} >>> list1 =
>>> list2 = list1.reverse()
>>> print(list2)
None
>>> type(list2)
<class 'NoneType'>
>>> type(list1.reverse())
<class 'NoneType'>
>>>
s.reverse() reverses the items of s in place
Note:The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don’t return the sorted or reversed list. >>> list1 =
>>> list1
>>> list1.reverse()
>>> list1
>>> list2 = list1
>>> list2
>>> list3 = list2[-1::-1]
>>> list3
>>> lubcat 发表于 2017-3-4 21:16
谢谢啦 donkkong 发表于 2017-3-4 22:07
>>> list1 =
>>> list1
嗯嗯 会啦 谢谢啦 不客气,加油
页:
[1]