python写入csv(解决了乱码问题)

import csv


def save_file(file_path, title, data):
    with open(file_path, 'a', newline='', encoding='utf-8-sig') as csvfile:
        spamwriter = csv.writer(csvfile)
        spamwriter.writerow(title)
        for i in data:
            spamwriter.writerow(i)

 

你可能感兴趣的:(Python)