Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file.
When I check back the file, I am getting indent error. How to fix this issue. reading_file = open("myfile.py", "r") new_file_content = "" for line in reading_file: stripped_line = line.strip() # print (stripped_line) if (stripped_line.find('siteip = ') != -1): stripped_line = "siteip = \"%s\"" %(siteip) new_line = stripped_line new_file_content += new_line +"\n" reading_file.close() writing_file = open("myfile", "w") writing_file.write(new_file_content) writing_file.close() -- https://mail.python.org/mailman/listinfo/python-list