zoukankan      html  css  js  c++  java
  • Python 数据编码 encode decode

    u = u'中文' #显示指定unicode类型对象u
    str = u.encode('gb2312') #以gb2312编码对unicode对像进行编码
    str1 = u.encode('gbk') #以gbk编码对unicode对像进行编码
    str2 = u.encode('utf-8') #以utf-8编码对unicode对像进行编码
    u1 = str.decode('gb2312')#以gb2312编码对字符串str进行解码,以获取unicode
    u2 = str.decode('utf-8')#如果以utf-8的编码对str进行解码得到的结果,将无法还原原来的unicode类型
    encode #编码
    decode #解码

     列表进行编码,将使用json转包后才可以编码

    dirList = [随意]
    strDirList = json.dumps(dirList)
    strDirList=strDirList.encode('gb2312')
  • 相关阅读:
    http返回码
    WCF 超时
    MVC异步
    熔断设计模式
    JAVA学习图
    java io模型
    keep alive 长连接
    Java异常处理 误区
    架构的本质
    Repository模式
  • 原文地址:https://www.cnblogs.com/ScarecrowMark/p/11283756.html
Copyright © 2011-2022 走看看