Python列表争用

2024-04-23 15:25:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我拿了一张这样的单子

[[x, a, d], [y], [z,f]]

它用这个来争论名单

#tag to print is the raw JSON
        for tagElement in tagToPrint[x]:
            if tagElement not in allConstrainedTagList:
                if v == 0:
                    topicTagConcat = [tagElement]
                    topicTagToPrint[x] = tagElement
                    v = v + 1
                elif v >= 1:
                    topicTagConcat = [topicTagConcat, tagElement]
                    topicTagToPrint[x] = topicTagConcat
                    v = v + 1

然后用这个

with open("output.csv", 'wb') as outcsv:
    #configure writer to write standard csv file
    writer = csv.writer(outcsv, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
    writer.writerow(['Topic Tag', ..... ])
    while x < y:
        writer.writerow(rowPrinter[x])
        x = x + 1

把这个打印出来

ID ColA ColB ColC
1   X    A    D
2   Y         
3   Z         F

如何将A&B&C作为一个列一起分析?十、 Y,Z,A,B,C是 同一列。它正在上演。你知道吗


Tags: csvtoinifistag单子writer