其他分享
首页 > 其他分享> > 列表的增

列表的增

作者:互联网

##################################################################################增
#append insert
#添加xiaoming到列表中
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a.append("xiaoming")
print(a)



输出结果:

['xiaoxing', 'xiaoliu', 'xiaozhang', 'xiaohong', 'xiaoli', 'xiaozhao', 'xiaoming']

  




#添加xiaoming到列表中第3个位置后:
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a.insert(3,"xiaoming")
print(a)



输出结果:
['xiaoxing', 'xiaoliu', 'xiaozhang', 'xiaoming', 'xiaohong', 'xiaoli', 'xiaozhao']

  

标签:xiaoming,xiaozhang,xiaoxing,xiaozhao,xiaoli,xiaohong,列表
来源: https://www.cnblogs.com/daino/p/11856036.html