如何使用 Python 在 csv 行的末尾写入列表的单个元素?

How to write single elements of a list at the end of a csv line with Python?

下面的代码将完整列表 ['x', 'y', 'z'] 添加为 csv 的单个元素。我想要得到的是行尾的 'x'; 'y'; 'z'; 。怎么样?

import csv
toto = ['x', 'y', 'z']
with open('res.csv', 'w', newline='') as resfile:
    reswriter = csv.writer(resfile, delimiter=';')
    reswriter.writerow(['Number', 'A', 'B', 'X', 'Y', 'Z'])    # header.
    reswriter.writerow(['001', 'a', 'b', toto])

将星号 * 添加到 toto:

import csv
toto = ['x', 'y', 'z']
with open('res.csv', 'w', newline='') as resfile:
    reswriter = csv.writer(resfile, delimiter=';')
    reswriter.writerow(['Number', 'A', 'B', 'X', 'Y', 'Z'])    # header.
    reswriter.writerow(['001', 'a', 'b', *toto])   # <--- note the *

res.csv:

Number;A;B;X;Y;Z
001;a;b;x;y;z