Page 1 of 1

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

Unread postPosted: 08 Dec 2021, 21:21
by 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: Select all
## 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 +

Unread postPosted: 08 Dec 2021, 21:28
by 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: Select all
## 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 +

Unread postPosted: 08 Dec 2021, 21:34
by cyberespia
Excellent merci. :yo: