Issue
I'm new and I have no idea where the default directory for the open()
function is.
For example open('whereisthisdirectory.txt','r')
Can someone advise me? I've tried googling it (and looking on stackoverflow) and even putting a random txt file in so many folders but I still can't figure it out. Since I'm beginning, I want to learn immediately rather than type "c:/directory/whatevevr.txt" every time I want to open a file. Thanks!
Ps my python directory has been installed to C:\Python32 and I'm using 3.2
Solution
os.getcwd()
Shows the current working directory, that's what open
uses for for relative paths.
You can change it with os.chdir
.
Answered By - dav1d
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.