我正在学习列表理解,我想知道是否可以为子列表分配新值。
newConfig = ['0', '0']
original = open("ciscoconf.txt", "r")
originalList = original.read().split("!")
originalLen = len(originalLen) - 1
for i in range(1, originalLen):
originalList[i] = originalList[i].split("\n")
newConfig[0] = input(str("New IP"))
for i in range(originalLen):
q = 0
for k in originalList[i]:
if k.find('ip address') == 0:
originalList[i][q] = "ip address " + " ".join(newConfig)
q += 1