When I tell python to create a new file and write in it, it tells me that the directory does not exist.
Ive tried multiple solutions, using "with open()" , changing around the 'w' to 'w+' and so on.
if not os.path.exists(os.getcwd()+'/bin'):
os.makedirs(os.getcwd()+'/bin/json')
with open(os.getcwd()+'/bin/misc/names.txt', 'w+') as file:
file.write('Ie`v(Janrkov(Uqjc=uv(Nvk(AJD=SO(F]u?(>-(=>(AO]r(=`nh(Koeneo(O]ldena(O]i(Iuhao(UCej(ING')
The error message is as follows
Bens-Air:Drug Empire Ben$ /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 "/Users/Ben/Desktop/Code/Drug Empire/main.py"
Traceback (most recent call last):
File "/Users/Ben/Desktop/Code/Drug Empire/main.py", line 27, in <module>
with open(os.getcwd()+'/bin/misc/names.txt', 'w+') as file:
FileNotFoundError: [Errno 2] No such file or directory: '/Users/Ben/Desktop/Code/Drug Empire/bin/misc/names.txt'
Any help is greatly appreciated, thanks in advance.
/bin/jsonbut creating the file at/bin/miscmaybe this is creating the problemworw+the file will be created if not exists, but not the directory. The directory/bin/misc/doesn't exist apparently