문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top