OK, so when I use open(<filename>, 'w') the program either writes to the specified file or creates a new one if it doesn't exist, right? Is there a way to create a folder path or something? Like to create D:\My Documents\Folder and create a file in that folder? How would I do that?
bobstein
0
Newbie Poster
Recommended Answers
Jump to Postsee documentation of 'os' module
Jump to PostYou must double the escape characters
\
ie\\
or use raw strings by adding before quotes or use / instead of\
. You can also buuld the path dynamically by os.path.joinNext time start your own thread, please!
All 9 Replies
scru
909
Posting Virtuoso
Featured Poster
bobstein
0
Newbie Poster
lllllIllIlllI
178
Veteran Poster
Da Krazy Jak
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
NeoNmaN
0
Newbie Poster
byonabz
0
Newbie Poster
3e0jUn
commented:
You must use os.makedirs("C:\Journal") instead of the other one.
+0
3e0jUn
0
Light Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
3e0jUn
commented:
Hmm... Who are you talking to?
+0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.