python 2.7


In [1]:
a = 10

In [2]:
b = unicode(a)

In [3]:
b


Out[3]:
u'10'

In [4]:
c = u'abc'

In [5]:
c


Out[5]:
u'abc'

In [6]:
unicode(c)


Out[6]:
u'abc'

In [9]:
d = u'aąćżź'

In [14]:
e = d.encode('utf-8')

In [15]:
e


Out[15]:
'a\xc4\x85\xc4\x87\xc5\xbc\xc5\xba'

In [13]:
d


Out[13]:
u'a\u0105\u0107\u017c\u017a'

In [16]:
print d


aąćżź

In [17]:
print e


aąćżź

In [18]:
g = {'a':'ąąą', 'b':'ććć'}

In [19]:
print g


{'a': '\xc4\x85\xc4\x85\xc4\x85', 'b': '\xc4\x87\xc4\x87\xc4\x87'}

In [20]:
print g['a']


ąąą

In [21]:
f = open('test', 'w')

In [22]:
f


Out[22]:
<open file 'test', mode 'w' at 0x0000000003DD1270>

In [24]:
f.write(g['a'])

In [25]:
f.close()

In [26]:
f = open('test', 'r')

In [29]:
inn = f.read()
print inn


ąąą

In [31]:
f.close()

In [ ]: