Python理论问题 我想学习为什么" print(i.extend(j))" DOESN' T工作。 它的输出是:"无"。 print(j)DOES work(它的输出是:" [4,5,6,7,8,9]")
i = [1, 2, 3]
j = [4, 5, 6]
k = [7, 8, 9]
# I'd like to learn theory as to why following doesn't work
# OUTPUT is: "None"
print(i.extend(j))
# Following does work (OUTPUT is: "[1, 2, 3, 4, 5]")
j.extend(k)
print(j)
答案 0 :(得分:-1)
答案很简单 -
extend不返回任何内容,并且任何不返回值的函数都将返回None。