How to print a container object using a value containing Unicode?

The following code

# -*- coding: utf-8 -*-
x = (u 'abc/αβγ',)
print x
print x[0]
print unicode(x).encode('utf-8')
print x[0]. encode('utf-8')

…Production:

(u'abc/αβγ',)
abc/αβγ
(u'abc/αβγ',)
abc/αβγ

Is there a way to make Python print

('abc/αβγ',)

Isn’t it necessary for me to construct the string representation of the tuple by myself? (I mean stringing “(“, “”, “encoded value”, “”, “,” and “)” together?

By the way, I am using Python 2.7. 1.

Thank you!

You can use’raw_unicode_escape’ to decode tuples The str said.

In [25]: print str(x).decode('raw_unicode_escape')
(u'abc/αβγ', )

The following code

# -*- coding: utf-8 -*-
x = (u'abc/αβγ',)
print x
print x[0]
print unicode(x).encode('utf-8')
print x[0].encode('utf-8')

…Production:

(u'abc/αβγ', )
abc/αβγ
(u'abc/αβγ',)
abc/αβγ

Is there a way to make Python print

('abc/αβγ',)

Does this do not require me to construct the string representation of the tuple by myself? (I mean “(“,”” , “Code value”, “”, “,” and “)” together?

By the way, I am using Python 2.7.1.

Thank you!< /p>

You can use’raw_unicode_escape’ to decode the str representation of the tuple.

In [25 ]: print str(x).decode('raw_unicode_escape')
(u'abc/αβγ',)

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4957 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.