写入csv文件时编码错误

问题遇到的现象和发生背景

python爬虫写入csv文件时编码错误

用代码块功能插入代码,请勿粘贴截图
with open('taobao2.csv', 'w', encoding='ANSI', newline='') as filename:
    csvwriter=csv.DictWriter(filename,fieldnames=['标题','价格','付款人数','店铺名称','地点','商品详情','店铺链接','图片链接'])
  #中间是爬虫的代码内容
        for index in data:
            dict={'标题':index['raw_title'],
          '价格':index['view_price'],
          '付款人数':index['view_sales'],
          '店铺名称':index['shopName'],
          '地点': index['item_loc'],
          '商品详情':'https:'+index[ 'comment_url'],
          '店铺链接':'https:'+index['shopLink'],
          '图片链接':'https:'+index['pic_url']
          }
    #将数据写入文件
            csvwriter.writerow(dict)
            print(dict)

运行结果及报错内容

UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character

我的解答思路和尝试过的方法

使用utf-8编码 但是会生成乱码

我想要达到的结果

生成的内容不会乱码而且能够运行程序

将你的代码在记事本里面打开,另存为UTF8编码

'wb+'