def out_u(s):
'''Return unicode string suitable for displaying
Unlike other functions assumes get_preferred_output_encoding() first. Unlike
u() does not throw exceptions for invalid unicode strings. Unlike
safe_unicode() does throw an exception if object is not a string.
'''
if isinstance(s, unicode):
return s
elif isinstance(s, bytes):
return unicode(s, get_preferred_output_encoding(), 'powerline_decode_error')
else:
raise TypeError('Expected unicode or bytes instance, got {0}'.format(repr(type(s))))
评论列表
文章目录