Category index for “unicode”

  • Unicode string formatting

    Did you know, if one of values in string formatting expression with % operator is unicode, then result string will also be unicode?

    >>> "Hello, %s" % u"Alex"
    u'Hello, Alex'
    >>> "Hello, %s" % u"Алексей"
    u'Hello, \u0410\u043b\u0435\u043a\u0441\u0435\u0439'
    
    Comments Read More
  • Parse url which contains unicode query, using urlparse.parse_qs

    Task: get dictionary of URL GET query. For example, we have following url:

    http://example.com/?key=value&a=b
    

    it is needed to get a dict:

    {'key': ['value'], 'a': ['b']}
    

    Values are lists, because one key may have several values:

    In: http://example.com/?key=value&a=b&a=c
    Out: {'key': ['value'], 'a': ['b', 'c']}
    
    Comments Read More