Python - \n interfering
<p>Hopefully a quick for for this one. I have a script replacing a specific value with a file location. The location unfortunetly seems to quite often contain \n or n\ in (it because the current directory is in the temp folders), causing the line to either break or remove itself from the line entirely making the folder location invalid.</p>

<p>The temp dir usually looks something like this.</p>

<pre><code>C:\Users\Admin\AppData\Local\Temp\nsfCDAC.tmp\Firefox
</code></pre>

<p>Is there a way to prevent \n or n\ from executing? Any help is appreciated, and here's what my line replacement script looks like. Thanks in advance!</p>

<pre><code>      #Editing Prefs.fs
        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)

        replaceAll(rootDir + "/Firefox/Data/prefs.js",'FirefoxAppDirHere',rootDir + "\\FirefoxApp.exe")
</code></pre>

<p><strong>EDIT:</strong></p>

<p>eryksun method that he commented with on this post worked perfectly for me! Thanks a lot! I'd mark the question as solved but you must make a post first.</p>
