Export a simple Dictionary into Excel file in python

后端 未结 2 1354
南笙
南笙 2020-12-31 20:19

I am new to python. I have a simple dictionary for which the key and values are as follows

dict1 = {\"number of storage arrays\": 45, \"number of ports\":239         


        
2条回答
  •  梦毁少年i
    2020-12-31 20:44

    You can use pandas.

    import pandas as pd
    
    dict1 = {"number of storage arrays": 45, "number of ports":2390}
    
    df = pd.DataFrame(data=dict1, index=[0])
    
    df = (df.T)
    
    print (df)
    
    df.to_excel('dict1.xlsx')
    

提交回复
热议问题