写入csv

作者: 还是那个没头脑 | 来源:发表于2021-05-24 16:24 被阅读0次
    import csv
    import os.path
    
    filename = 'notice.csv'
    file_exists = os.path.isfile(filename)
    
    def writeCSV(appName,title,description,orignUrl):
    
        rows = [appName, title, description, orignUrl]
    
        with open(filename, 'a+', encoding='utf-8-sig')as csvfile:
            headers = ['appName', 'title', 'description', 'orignUrl']
            writer = csv.writer(csvfile)
    
            if not file_exists:
                writer.writerow(headers)
    
            writer.writerow(rows)
    
    writeCSV("人民日报", '起风了','大风起兮云飞扬','https://wap.peopleapp.com/article/rmh20732791/rmh20732791')
    

    相关文章

      网友评论

          本文标题:写入csv

          本文链接:https://www.haomeiwen.com/subject/tnixsltx.html