Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

open() is not creating a new file [duplicate]

$
0
0

I am trying to create a text file and write to it but the file is not being created as it states the file is not found.

I am using this line of code which PyCharm as my IDE:

with open(f"journal/{date}.txt","w") as file:

And I am expecting python to create the file but it is not. The folder in which to create the file does exist. I am receiving the error:

FileNotFoundError: [Errno 2] No such file or directory: 'journal/2024-01-25.txt'

I am new to python so any assistance would be greatly appreciated.

Thank you


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>