为什么 ist 值打印 ist "None",即使在 backgroud 中反向功能工作正常 [python] [谢谢]?
法典:
aList = ["a", "b", "c", "d", "e", "f", "g"]
print(aList)
['g', 'f', 'e', 'd', 'c', 'b', 'a']
print(aList.reverse())
None
在 Python 中,list.reverse()
不返回任何内容 - 它只是反转列表(就像它修改实际列表一样)。要查看反转列表,请在运行 list.reverse()
后查看list
,或使用reversed(list)
查看反转列表而不实际反转它。