import fileinput filename = ‘passwd‘ for line in fileinput.input(filename,inplace=1,backup=‘.bak‘) print line.replace(‘root‘,‘ROOT‘)
时间: 2024-11-08 20:38:41
import fileinput filename = ‘passwd‘ for line in fileinput.input(filename,inplace=1,backup=‘.bak‘) print line.replace(‘root‘,‘ROOT‘)