Page 1 sur 1

Afficher les données dans un tableau - python graph 90 + e

Message non luPosté: 08 Déc 2021, 21:21
de cyberespia
Il existe un moyen d'afficher des données tabulées, c'est-à-dire dans un tableau.
J'ai testé ce code, mais il le montre horizontalement

Code: Tout sélectionner
## Python program to print the data
d = {1: ["Python", 33.2, 'UP'],2: ["Java", 23.54, 'DOWN'],3: ["Ruby", 17.22, 'UP'],10: ["Lua", 10.55, 'DOWN'],5: ["Groovy", 9.22, 'DOWN'],6: ["C", 1.55, 'UP'] }
print ("{:<8} {:<15} {:<10} {:<10}".format('Pos','Lang','Percent','Change'))
for k, v in d.items():
  lang, perc, change = v
print ("{:<8} {:<15} {:<10} {:<10}".format(k, lang, perc, change))


Il existe un autre moyen ou bibliothèque d'utiliser et d'afficher des données dans des tableaux. si possible avec scroll

Re: Afficher les données dans un tableau - python graph 90 +

Message non luPosté: 08 Déc 2021, 21:28
de critor
À un tout petit problème d'indentation près, ton code marche très bien et tu peux bien scroller une fois terminé :
Code: Tout sélectionner
## Python program to print the data
d = {1: ["Python", 33.2, 'UP'],2: ["Java", 23.54, 'DOWN'],3: ["Ruby", 17.22, 'UP'],10: ["Lua", 10.55, 'DOWN'],5: ["Groovy", 9.22, 'DOWN'],6: ["C", 1.55, 'UP'] }
print ("{:<8} {:<15} {:<10} {:<10}".format('Pos','Lang','Percent','Change'))
for k, v in d.items():
  lang, perc, change = v
  print ("{:<8} {:<15} {:<10} {:<10}".format(k, lang, perc, change))

Image

Re: Afficher les données dans un tableau - python graph 90 +

Message non luPosté: 08 Déc 2021, 21:34
de cyberespia
Excellent merci. :yo: