I am trying to create a text file using python. Here is my code-
import sys
import os
str1="a1.txt"
file1="Documents/Inbox/"
completeName=file1+str1
name1=os.path.abspath(completeName)
myfile = open(name1, 'w')
I want to save file a1.txt in my documents folder in my home directory.I get the following error using above code-
Traceback (most recent call last):
File "filesave.py", line 8, in <module>
myfile = open(name1, 'w')
FileNotFoundError: [Errno 2] No such file or directory: '/home/pulkit/Documents/Documents/Inbox/a1.txt'
/home/pulkit/Documents/Documents/Inboxexist?file1="Inbox/"~/Documents, anyway. While it looks like the folks at FreeDesktop failed to document the "well known" directories in a real specification (arch wiki with non-normative documentation), but the accompanying library makes it clear, that the documents directory is user configurable.