Browse Source

lecture des fichiers de donnee

master
nemesis 2 years ago
parent
commit
ea3cf1bf9b
  1. 42
      lecture.py

42
lecture.py

@ -0,0 +1,42 @@
#!/usr/bin/python
# coding: utf8
import pickle
import sys
contenu = {}
def charger(fic):
global contenu
try:
with open(fic, "rb") as fichier:
loader = pickle.Unpickler(fichier)
contenu = loader.load()
except:
clock = {}
if (len(sys.argv) is 2):
charger(sys.argv[1])
try:
for valeur in contenu:
obj = contenu[valeur]
try:
for val in obj:
print(valeur + " : " + val)
except:
for cle,val in obj.items():
print(cle[0] + " : " + cle[1] + " : " + val)
except:
try:
for cle,val in contenu.items():
for key,value in val.items():
print(str(cle) + ":" + str(key) + " : " + str(value))
except:
try:
for cle,val in contenu.items():
if (val):
print(cle[0] + ":" + cle[1])
except:
print("KABOUM!")
else:
print("lecture.py <fichier>")
Loading…
Cancel
Save