import sys if __name__ == "__main__": projectsetting = sys.argv[1] enable = sys.argv[2] if enable == "true": sys.exit() flag = False newData = "" print("start delete define") with open(projectsetting, 'r') as f: for line in f: if flag ==True and (";USE_LOGWRAPPER" in line) and ("7" in line): print("delete define") line = line.replace(";USE_LOGWRAPPER","") if "scriptingDefineSymbols:" in line: flag = True print("already delete") newData += line with open(projectsetting,"w",encoding="utf-8") as f: f.write(newData)