0

I have a list with Unicode utf-8 tuples like:

((u'\u0d2a\u0d31\u0d1e\u0d4d\u0d1e\u0d41', u'\u0d15\u0d47\u0d3e\u0d23\u0d4d\u200d\u0d17\u0d4d\u0d30\u0d38\u0d4d'), 7.5860818562067314)

I want to convert the utf-8 code as string. I have tried decode. But getting error. Can anyone please help me out?

Thanks in advance!

2 Answers 2

1

You should use .encode('utf-8') method instead of .decode(), because strings are represented in unicode type, and we want to get byte strings.

Here is great how-to about string encoding in python 2.7, must read it: http://docs.python.org/2/howto/unicode.html

For example, data[0][0].encode('utf-8') produces normal result.

Sign up to request clarification or add additional context in comments.

1 Comment

Please format your code in your answer properly. Otherwise, good answer
0

Those are not UTF-8.

print data[0][0], data[0][1]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.