2023-11-05 08:47:10

添加编码格式:

encoding='utf_8_sig'
def saveColumnNameToCSV(OSSPath,rowsInfo):
    with open(OSSPath,"w",newline='',encoding='utf_8_sig') as f:
        headers=["No","OSS","License","Feature","Type","Version","Encription","Modification","Comment","Homepage","License in statement ","Link to License template"]
        fcsv = csv.DictWriter(f,headers)
        fcsv.writeheader()
        fcsv.writerows(rowsInfo)

##rowinfos是一个list类型
##[ {"NO":1,"OSS":2,,,,"Link to License template":3} 
## {"NO":3,"OSS":4,,,,"Link to License template":5} ]

 解决方法来源:

https://blog.csdn.net/anchor164/article/details/104998937

上一篇:UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 68: illegal multib


下一篇:UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 3136: illegal mult