import fileinput

filename = 'passwd'

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

    print line.replace('root','ROOT')

 

a = ' this is apple'
a.replace('this','that')

对字符串的替换

 

相关文章:

  • 2021-08-23
  • 2021-11-27
  • 2022-12-23
  • 2021-07-02
  • 2021-08-22
  • 2021-09-13
  • 2021-07-31
  • 2021-07-26
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2021-05-26
  • 2022-12-23
  • 2021-11-26
  • 2021-05-30
  • 2022-03-09
相关资源
相似解决方案