如何将 list1 或 list2 中的每个列表打印为不包含 '[ ]' 的列?
import csv
def test():
list1 = [[1, 2, 3, 4], [3, 2, 5], [9, 3, 6, 8, 4]]
list2 = [[2, 2, 4, 4], [1, 9, 10], [2, 7, 7, 4, 5]]
with open('doc.csv', 'w', newline='') as file:
writer = csv.writer(file, quotechar='"', quoting=csv.QUOTE_ALL)
writer.writerow(list1)
writer.writerow(list2)
if __name__ == '__main__':
test()
这接近我想要的但在字符串中有 [ ] :
[1, 2, 3, 4],[3, 2, 5],[9, 3, 6, 8, 4]
[2, 2, 4, 4],[1, 9, 10],[2, 7, 7, 4, 5]
编辑:
我想:
"1, 2, 3, 4","3, 2, 5","9, 3, 6, 8, 4"
"2, 2, 4, 4","1, 9, 10","2, 7, 7, 4, 5"