-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfichiers.py
More file actions
42 lines (30 loc) · 1.07 KB
/
Copy pathfichiers.py
File metadata and controls
42 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*-coding:Latin-1 -*
import os
print("Répertoire courant : "+os.getcwd())
print("Changement de répertoire pour c:/tmp")
os.chdir(("c:/tmp"))
print("Répertoire courant : "+os.getcwd())
print("Création répertoire c:/tmp/gg")
try:
os.mkdir("gg")
except:
print("Répertoire déjà crée")
print("Création ficher c:/tmp/gg/fichier.txt")
fichier=open("c:/tmp/gg/fichier.txt", 'w')
print("Ecriture dans le ficher c:/tmp/gg/fichier.txt")
fichier.write("Test écriture")
print("Fermeture ficher c:/tmp/gg/fichier.txt")
fichier.close()
print("Overture ficher lecture c:/tmp/gg/fichier.txt")
fichier=open("c:/tmp/gg/fichier.txt", 'r')
print("Lecture dans le ficher c:/tmp/gg/fichier.txt")
ligne = fichier.read()
print("Ligne lue : "+ligne)
print("Fermeture ficher c:/tmp/gg/fichier.txt")
fichier.close()
print("Overture fichier lecture avec with c:/tmp/gg/fichier.txt")
with open("c:/tmp/gg/fichier.txt", 'r') as fichier:
print("Lecture dans le ficher c:/tmp/gg/fichier.txt")
ligne = fichier.read()
print("Ligne lue : "+ligne)
print("Fichier fermé ?:"+str(fichier.closed))