zoukankan      html  css  js  c++  java
  • python写文件时遇到UnicodeEncodeError: 'gbk' codec can't encode character的解决方式

    在window平台,文件的默认编码是gbk, 此时如果写入的字符串的编码是utf-8就会引发这种错误,打开文件的编码必须与字符串的编码一致

    with open(‘content.txt’,'w',encoding='utf-8')  as f:

      r.write()

    这样就不会报错

    原创链接:https://blog.csdn.net/life_is_too_hard/article/details/78384562

  • 相关阅读:
    linux sed命令详解
    SQL注入基础知识
    DC-7
    DC-6
    DC-5
    DC-4
    DC-3
    DC-2
    pentestlabs
    任意文件读取和下载
  • 原文地址:https://www.cnblogs.com/sneike/p/8879039.html
Copyright © 2011-2022 走看看