![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | cheo |
Is there a way to print the content of a dictionary in plain text excluding the json format?
print(JSON.print(dictionary, "\t"))
will return:
{
"Item1": 4,
"Item2": 3
}
print(dictionary)
will return:
{Item1:4,Item2:3}
I’d like to have it formatted like this:
Item1 : 4
Item2 : 3
The result will be used in a label to list all the content of the dictionary.
This code works for the console, but not for the label, as it only shows the last key:value pair of the dictionary:
for i in dictionary:
print("%s : %d" % [i, dictionary[i]])
So I’m struggling to translate this to a label