其他分享
首页 > 其他分享> > 解决 UnicodeEncodeError: 'gbk' codec can't encode character '\u2714' in posi

解决 UnicodeEncodeError: 'gbk' codec can't encode character '\u2714' in posi

作者:互联网

添加编码格式:

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

标签:License,sequence,##,illegal,OSS,multibyte,fcsv,Link,template
来源: https://www.cnblogs.com/fool-jingqiu/p/14387626.html