The open () function


#1



https://www.codecademy.com/fr/courses/python-intermediate-fr-FR-i3pwf/0/2?curriculum_id=5370f030fed2a866a2000001#


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


mon_fichier=open("output.txt","r+")


#2

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 "


#3

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


#4

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 ..


#5

your code is fine, this simply is a bug.


#6

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")
mon_fichier.close()

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

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

#7

thank you @appylpye @stetim94


#8