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

列表的改

作者:互联网

#替换掉xiaozhang的值,修改为xiaoming
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a[2]="xiaoming"
print(a)

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

  




#替换掉xiaozhang,xiaohong的值,修改为b,c
a=['xiaoxing','xiaoliu','xiaozhang','xiaohong','xiaoli','xiaozhao']
a[2:4]=["b","c"]
print(a)

输出结果:
['xiaoxing', 'xiaoliu', 'b', 'c', 'xiaoli', 'xiaozhao']

  

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