Import all
This commit is contained in:
16
Formations/NSI/Bloc1/diubloc1-files-td6/display_file.py
Normal file
16
Formations/NSI/Bloc1/diubloc1-files-td6/display_file.py
Normal file
@@ -0,0 +1,16 @@
|
||||
def display_file(name):
|
||||
with open(name, 'rb') as f:
|
||||
print("Voici les dix premiers caractères du fichier " +
|
||||
name + " :")
|
||||
for i in range(10):
|
||||
c = f.read(1)
|
||||
if len(c) == 0: # vrai si on est arrivé à la fin du fichier
|
||||
break
|
||||
print("Position " + str(i) + " : '" + c.decode('latin1') +
|
||||
"' (code ASCII = " + str(ord(c)) + ")")
|
||||
|
||||
|
||||
display_file('traitement-de-texte.odt')
|
||||
display_file('lyon1.png')
|
||||
display_file('display_file.py')
|
||||
display_file('donnees-2-colonnes.csv')
|
||||
@@ -0,0 +1,3 @@
|
||||
0, 10
|
||||
1, 12
|
||||
4, 15
|
||||
|
5
Formations/NSI/Bloc1/diubloc1-files-td6/donnees.txt
Normal file
5
Formations/NSI/Bloc1/diubloc1-files-td6/donnees.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
1
|
||||
12.3
|
||||
43
|
||||
3
|
||||
10
|
||||
9
Formations/NSI/Bloc1/diubloc1-files-td6/ex_csvlib.py
Normal file
9
Formations/NSI/Bloc1/diubloc1-files-td6/ex_csvlib.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# cf https://docs.python.org/fr/3/library/csv.html
|
||||
|
||||
import csv
|
||||
|
||||
fieldnames = ['x', 'y']
|
||||
with open('donnees-2-colonnes.csv', newline='') as csvfile:
|
||||
reader = csv.DictReader(csvfile, fieldnames=fieldnames)
|
||||
for row in reader:
|
||||
print(row['x'], row['y'])
|
||||
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/lyon1.jpg
Normal file
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/lyon1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 253 KiB |
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/lyon1.png
Normal file
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/lyon1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 212 KiB |
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/traitement-de-texte.odt
Normal file
BIN
Formations/NSI/Bloc1/diubloc1-files-td6/traitement-de-texte.odt
Normal file
Binary file not shown.
Reference in New Issue
Block a user