而extend 方法的参数只能是列表,不能是元素。extend 方法将参数中的列表中的元素(而不是参数列表)作为元素逐一加入列表,例如:
>>>list1=[1,2,3,4,5,6]>>>list1.extend(7)Traceback(mostrecentcalllast):File"<pyshell#1>",line1,in<module>list1.extend(7)TypeError:'int'objectisnotiterable>>>list1.extend([8,9])>>>list1[1,2,3,4,5,6,8,9]