How To Write File In A Different Directory In Python?
I am working on Linux with python 2.7.x and I am running some programs python through terminal. I want the certain output should be written in a file located at different directory
Solution 1:
Changing the current directory with os.system
will not affect the Python process that’s running. Just open the file with its full path directly:
with open('/pr/p1/ap11/All.txt', 'a') as output:
output.write('hello\n')
Post a Comment for "How To Write File In A Different Directory In Python?"