Dictionary corrupt the name of the key [Python] -


my problem when input accent dictionary stores different keyname, replace accented character wit character code. i'm new here accept every help. thank help!

#!/usr/bin/python # -*- coding: utf-8 -*-  products={} try:     prodnum = int(raw_input(u"hány terméket kíván felvenni listába?\r\n"))     count   = 0      while (count < prodnum):         prodname            = raw_input(u"kérem üsse %d. termék nevét!\r\n" %(count + 1))         encodedname = prodname.decode('utf8')         print(encodedname)         prodval             = int(raw_input(u"kérem üsse %d. termék darabszámát!\r\n" %(count + 1)))           products[encodedname]  = prodval         count               = count + 1 except valueerror:     print (u"ide egy számot kellett volna írni. :)\r\n")  print(products)  output: hány terméket kíván felvenni listába? 1 kérem üsse 1. termék nevét! qpa kóla qpa kóla kérem üsse 1. termék darabszámát! 2 {u'qpa k\xf3la': 2} 

printing container prints representation of contents. there no bug, merely misplaced expectations.

>>> print u'qpa k\xf3la' qpa kóla >>> print repr(u'qpa k\xf3la') u'qpa k\xf3la' 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -