Apr-25-2019, 08:12 PM
test.txt
Output:stuff
more stuff
ASCII "C:\Windows\Temporary Internet Files\"
other stuff
paths = {r'ASCII "C:\Windows\Temporary Internet Files\"': r'ASCII "C:\Users\Edward\AppData\Local\Microsoft\Windows\Temporary Internet Files\"'} with open('test.txt', 'r') as infile, open('testout.txt', 'w') as outfile: for stuff in infile: stuff = stuff.strip() line = paths.get(stuff, stuff) outfile.write(f'{line}\n')testout.txt
Output:stuff
more stuff
ASCII "C:\Users\Edward\AppData\Local\Microsoft\Windows\Temporary Internet Files\"
other stuff