import fileinput

filename = 'passwd'

for line in fileinput.input(filename,inplace=,backup='.bak')

    print line.replace('root','ROOT')
a = ' this is apple'
a.replace('this','that') 对字符串的替换
05-08 08:27