Initial commit
This commit is contained in:
25
source/08-text-files/fileuse/textfile.py
Normal file
25
source/08-text-files/fileuse/textfile.py
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
def write_file():
|
||||
"""
|
||||
Écrire un fichier texte très simple.
|
||||
|
||||
"""
|
||||
f = open("demo.txt", "w")
|
||||
f.write("Contenu de notre fichier texte de démo e!")
|
||||
f.close()
|
||||
|
||||
|
||||
def read_file():
|
||||
"""
|
||||
Lire dans un fichier texte très simple.
|
||||
|
||||
"""
|
||||
f = open("demo.txt", "r")
|
||||
data = f.read()
|
||||
f.close()
|
||||
print(data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
write_file()
|
||||
read_file()
|
Reference in New Issue
Block a user