import os file_path = 'index.php' with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Fix the syntax error search_bad = 'echo "$tz";' replace_good = 'echo "