>>> fate = ['1','2','3','4','5']
>>> fate
['1', '2', '3', '4', '5']
>>> fate.extend(['a','b','c'])
>>> fate
['1', '2', '3', '4', '5', 'a', 'b', 'c']
extend(【 】)可以添加多个参数
顺便请问下为什么插入中文字符串正常但是插入英文名字会报错?
>>> fate
['1', '2', '3', '4', '5', 'a', 'b', 'c']
>>> fate.extend(['剑士','弓兵'])
>>>
>>> fate
['1', '2', '3', '4', '5', 'a', 'b', 'c', '剑士', '弓兵']
>>> fate,extend(['saber','archer'])
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
fate,extend(['saber','archer'])
NameError: name 'extend' is not defined |