我有以下默认字典。我正在尝试将字典的值写入文件。但它写在一行中。我想在每个项目后添加换行符。帮助 ?
defaultdict(<type 'list'>, {'11163722404385': [('#3\n', '2089', '', '', '', 'Con verted', '', '', '', 'Mon Apr 22 13:32:00 PDT 2013', 'UNATT')], '1116372240485':
[('#3\n', '2089', '', '', '', 'Converted', '', '', '', 'Mon Apr 22 13:31:00 PDT
2013', 'UNATT'), ('#3\n', '2089', '', '', '', 'Converted', '', '', '', 'Mon Apr
22 13:31:14 PDT 2013', 'UNATT'), ('#3\n', '2089', '', '', '', 'Converted', '',
'', '', 'Mon Apr 22 13:32:00 PDT 2013', 'UNATT')]})
accounts = defaultdict(list)
with open('C:\fileReport.txt', 'a') as csvoutput:
writer = csv.writer(csvoutput)
for sid,data1 in accounts.iteritems():
report = [';'.join(items) for items in data1]
print report
finalReport = ['{},{}'.format(sid, ''.join(report))]
writer.writerow(report)
writer.writerow('\n')