我有这样的档案
hostname ser1-xyz
myuser name
passwd secret
group 1234
hostname ser2-xyz
myuser name
passwd secret
group 2345
我需要找到名为“ser1xyz”的主机的第一个外观行并将其修改为 “ser1”并将组值递增1
最后的文件看起来像:
^{pr2}$目前我正在遵循代码,它可以将“ser1 xyz”修改为“ser1”
for line in fileinput.FileInput(fn,inplace=1):
line = line.replace(search,replace)
但是如何增加群体价值呢?在
单程
输出
^{pr2}$将
inplace=0
更改为inplace=1
进行就地编辑。在相关问题 更多 >
编程相关推荐