【发布时间】:2017-09-24 07:45:36
【问题描述】:
我在 python 中有 dict,我想将它附加到 CSV 文件和 Excel 文件中。
我有一个函数可以返回下面的字典
d = {'Engine': u'2.0 TSI MLB', 'Category': 'Category', 'Installation': 'Installation', 'Features': 'Features', 'Title': 'Title', 'Recommended Software': 'Recommended Software', 'UniCONNECT+': 'UniCONNECT+', 'Make': u'AUDI', 'Price': 'Price', 'Stock Power': 'Stock Power', 'Desctiption': 'Description', 'Related Hardware': 'Related Hardware', 'Year': u'2018', 'Hardware Included': 'Hardware Included', 'Model': u'A4', 'Product Type': 'Product Type', 'LB-FT': 'LB-FT', 'HP': 'HP', 'Octane': 'Octane', 'Media1': 'Media1'}
我已经从循环中调用了函数,并且函数返回具有不同数据的相同字典,我必须将其写入循环中的 CSV 和 Excel 文件 文件应如下所示
Engine | Category | Installation |........
2.0 TSI MLB | car | 5 |........
2.0 TSTI MLB | bike | 6 |........
8.0 BL | car | 8 |........
2.0 TSI MLB | car | 6 |........
【问题讨论】:
-
您需要什么样的帮助?请分享您的代码,向我们展示您迄今为止所做的尝试,并提出有效的问题以寻求帮助。
标签: python excel csv dictionary