Question

I need to print values that have non ascii symbols. These values are unicode strings. So I have this list:

some_list = [u'Data', u'Svoris', u'Perdavimo laikas', 
    u'\u012evykio vietos adresas', u'Kvietimo prie\u017eastis']

I can print it with with non ascii symbols, but u is still kept:

print 'hello %s' % (str(some_list)[1:-1].decode('unicode-escape'))

hello u'Data', u'Svoris', u'Perdavimo laikas', u'Įvykio vietos adresas', u'Kvietimo priežastis'

How can I hide u too?

Was it helpful?

Solution

You're printing the str of a list, and slicing off the [] brackets. Instead, join the strings together:

some_list = [u'Data', u'Svoris', u'Perdavimo laikas', 
    u'\u012evykio vietos adresas', u'Kvietimo prie\u017eastis']

print 'hello %s' % ', '.join(some_list)

Outputs:

hello Data, Svoris, Perdavimo laikas, Įvykio vietos adresas, Kvietimo priežastis

This also removes the ' quotes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top