def _some_str(value):
try:
if PY2:
# If there is a working __unicode__, great.
# Otherwise see if we can get a bytestring...
# Otherwise we fallback to unprintable.
try:
return unicode(value)
except:
return "b%s" % repr(str(value))
else:
# For Python3, bytestrings don't implicit decode, so its trivial.
return str(value)
except:
return '<unprintable %s object>' % type(value).__name__
# --
评论列表
文章目录