我从 SO 专家那里得到了以下代码,但它适用于 ANSI 字符串,我的输入是UNICODE STRING。如何使此代码适用于两个版本?TIA
import csv
from collections import defaultdict
summary = defaultdict(list)
csvin = csv.reader(open('qwetry.txt'), delimiter='|')
for row in csvin:
summary[(row[1].split()[0], row[2])].append(int(row[5]))
csvout = csv.writer(open('datacopy.out','wb'), delimiter='|')
for who, what in summary.iteritems():
csvout.writerow( [' '.join(who), len(what), sum(what)] )
礼貌:乔恩克莱门茨