Encoding

  • Encoding
  • example
    >>> a = "摩根斯坦利"
    >>> a
    '\xe6\x91\xa9\xe6\xa0\xb9\xe6\x96\xaf\xe5\x9d\xa6\xe5\x88\xa9'
    >>> b = u"摩根斯坦利"
    >>> b
    u'\u6469\u6839\u65af\u5766\u5229'
    >>> type(a)
    <type 'str'>
    >>> type(b)
    <type 'unicode'>
    >>> print a
    摩根斯坦利
    >>> print b
    摩根斯坦利
    >>> a.decode('utf-8')      
    u'\u6469\u6839\u65af\u5766\u5229'
    >>> b.encode('utf-8')
    '\xe6\x91\xa9\xe6\xa0\xb9\xe6\x96\xaf\xe5\x9d\xa6\xe5\x88\xa9'
    
Last modified 3 years ago Last modified on 12/22/16 16:28:24