def b(s):
# BSON and socket operations deal in binary data. In
# python 3 that means instances of `bytes`. In python
# 2.6 and 2.7 you can create an alias for `bytes` using
# the b prefix (e.g. b'foo'). Python 2.4 and 2.5 don't
# provide this marker so we provide this compat function.
# In python 3.x b('foo') results in b'foo'.
# See http://python3porting.com/problems.html#nicer-solutions
return codecs.latin_1_encode(s)[0]
评论列表
文章目录