zoukankan      html  css  js  c++  java
  • python混账的编码问题解决之道

    下面的代码作用是修改文件的编码格式。代码很简单,但是也很牛逼(在我看来),这是在segment上找到的解决办法,废话不多说,直接上代码。
    import codecs
    
    def ReadFile(filePath, encoding):
        with codecs.open(filePath, "r", encoding=encoding) as f:
        return f.read()
    
    def WriteFile(filePath, content, encoding):
        with codecs.open(filePath, "w", encoding=encoding) as f:
        f.write(content)
    
    def UTF8_to_GBK(src, dst):
        content = ReadFile(src, encoding="gbk")
        WriteFile(dst, content, "utf-8")
     
  • 相关阅读:
    php知识点
    CommonsChunkPlugin知识点
    待学习
    svn知识点
    es6知识点
    webpack2新特性
    排序算法
    交流措辞
    js继承
    多行编辑软件
  • 原文地址:https://www.cnblogs.com/marsggbo/p/6622911.html
Copyright © 2011-2022 走看看