import csv
import os

def main():

    current_dir = os.path.abspath('.')
    file_name = os.path.join(current_dir, "csss.csv")
    csvfile = open(file_name, 'wt',newline='')  # encoding='utf-8'

    writer=csv.writer(csvfile, delimiter=",")
    header=['uel','title']
    csvrow1=[]
    csvrow2=[]
    csvrow1.append("测试1")
    csvrow1.append("测试2")
    csvrow2.append("111")
    csvrow2.append("222")

    writer.writerow(header)
    writer.writerows(zip(csvrow1,csvrow2))


    csvfile.close()

if __name__ == '__main__':
    main()

效果:
python csv写入多列

相关文章:

  • 2022-02-16
  • 2021-12-18
  • 2021-06-07
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-04
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案