service = ['https','ftp','ssh','mysql']
# 通过索引,重新赋值
service[0] = 'http'
print(service)
# 通过切片赋值
service[:2] = ['samba','dns','firewalld']
print(service)
Python中列表元素的修改
最新推荐文章于 2024-07-16 13:58:30 发布
service = ['https','ftp','ssh','mysql']
# 通过索引,重新赋值
service[0] = 'http'
print(service)
# 通过切片赋值
service[:2] = ['samba','dns','firewalld']
print(service)