扩展函数的返回值(无)表示什么。
common_birds = ["chicken", "blue jay", "crow", "pigeon"]
birds_seen = ["sparrow", "green finch", "gold finch"]
print (common_birds.extend(birds_seen))
# returns None
common_birds.extend(birds_seen)
print (common_birds)
# returns the extended list
答案 0 :(得分:6)
这意味着该方法不返回任何内容,而是通过扩展列表来“就地”工作。您不是要返回新列表,而是要更改旧列表。
答案 1 :(得分:0)
这意味着该方法没有可以使用的结果。相反,它具有副作用。
希望唯一的副作用就是您所期望的副作用,即列表得到扩展。
在您的生活中,您会发现void
种方法具有多种副作用,其中有些是不需要的。