>>> cmd="echo ö"
>>> type(s1)
<str>
>>> print s1
echo ö
>>> chan.exec_command(cmd)
I am getting a string with some unicode characters from an external application. How should I handle this string in my python code properly? I am getting exception as below when I am sending this to paramiko exec_command
method. Here chan
is my Paramiko object.
'ascii' codec can't encode character u'\xfc' in position 136: ordinal not in range(128)
I need to encode/decode this string before sending it to paramiko. I am new to python, any help would be really appreciated. This was the string I am adding:
X0A3549029:[u'Uni\xf3n de Cr\xe9', u'DemoModel', 'NA']
Traceback (most recent call last):
File "updateTelemetry.py", line 98, in <module>
query="insert into record_tmp(sn,cname,model,product) values('"+key+"','"+value[0].decode('utf8')+"','"+value[1]+"','"+value[2]+"')"
File "/usr/lib64/python2.6/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 3: ordinal not in range(128)