>>> d = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
>>> ','.join(d.keys())
'key3,key2,key1'
>>> ','.join(d.values())
'value3,value2,value1'
python data dictionary output
-
30-07-2022 - |
Question
I have a list of key and values in a data dictionary format already
e.g.
{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}
How can this be put into a csv output where
key1,key2,key3
value1,value2,value3
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow