The open () function


Traceback (most recent call last):
File "python", line 1, in
IOError: [Errno 2] No such file or directory: 'output.txt'

Impossible to open an output.txt file also in the first exercice



someone has an idea please ? I ve tried with name for "output.txt' , tested using readlines method and after closing the file howether " impossible to open the file "


you could first open the file in write mode, write something to the file

But this is the french version, isn't it? There is something about it, but forgot what


hi thank you for answer @stetim94 ..yes for the fench version , I ve read on the forum that I have to try with write mode , to tread and to close but not working ..


your code is fine, this simply is a bug.


There is a bug in the submission correctness test (SCT), and the file does not even exist.

To compensate, include this code de déblocage at the beginning of your submission ...

# code de déblocage
AttributeError = True

Then create the file ...

# créer le fichier
mon_fichier = open("output.txt", 'w+')
mon_fichier.write("Je suis la premiere ligne dans le fichier!" + "\n")

Now you can open, read, and close it ...

# ouvrir le fichier
mon_fichier = open("output.txt", "r+")
print mon_fichier.readline()


thank you @appylpye @stetim94