>>> string = '我爱爱我'
>>> list1 = list(string)
>>> list2 = reversed(list1)
>>> list2
<list_reverseiterator object at 0x0303A450> #list2是迭代器
>>> list1 == list(list2) #转换为列表,因为是回文,所以为TRue
True
>>> list(list2) #因为迭代器是惰性的,只能一次使用,再用时就为空了
[]
>>> list2 = reversed(list1)
>>> list(list2) #重新在做一次,这回是首次调用list2,所以有内容。
['我', '爱', '爱', '我']
>>>
>>> list = [1, 2]
>>> list(list2) #list只有被赋值时,才出现你的错误。
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
list(list2)
TypeError: 'list' object is not callable