我想在python中编辑如下所示的conf文件:
# The username who should own the process.
USER_NAME=root
#The amount of time to wait for startup
# STARTUP_WAIT=30
我正在考虑更换线路,但由于某种原因,它无法正常工作。
def replaceAll(file,searchExp,replaceExp):
for line in fileinput.input(file, inplace=1):
if searchExp in line:
line = line.replace(searchExp,replaceExp)
sys.stdout.write(line)
有没有办法做到这一点,请帮助。