Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python uses wrong path to write files

I launch my py file from C:\Users\UserDirectory\OneDrive\Bureau\python. But when I want to load a file saved in python directory with the open() method, so in the same directory that my py file, python return the FileNotFoundError.

For example:

filename = 'test.txt'
with open(filename, 'r') as f:
    lines = f.read()

I guess it’s very simple problem to resolve but I could’nt by myself.
I noticed that when I use write(), it saves file in C:\Users\UserDirectory.
thanks for help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is a similar issue to yours. You could try some of the solutions mentioned there.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading