17 lines
563 B
Python
17 lines
563 B
Python
|
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')
|