标签:read readline file rom aml nested ESS env string
#!/usr/bin/python #coding:utf-8 """ """ import sys,os from contextlib import nested def MergeEnvFile(newfile,oldfile): with nested(open(newfile,‘a‘), open(oldfile, ‘r‘)) as (new_file, old_file) : old_file_lines = old_file.readlines(); new_file.write(‘\n‘); new_file.write(" env:"); new_file.write(‘\n‘); for line in old_file_lines: new_line = line.strip().replace("=",": ",1); #Process the second half of the string. line_key = new_line.strip().split(":",1)[0]; line_value = new_line.strip().split(":",1)[1]; new_line = line_key+": "+‘"‘+line_value.strip()+‘"‘; ############################### new_file.write(‘ ‘+new_line); new_file.write("\n"); new_file.close(); if __name__ == "__main__" : MergeEnvFile(‘temp.yaml‘,‘env‘);
标签:read readline file rom aml nested ESS env string
原文地址:https://www.cnblogs.com/songfucai/p/8782509.html