code: def to_binary(value, encoding='utf-8'):
      
      if not value:
          return b''
      if isinstance(value, six.binary_type):
          return value
      if isinstance(value, six.text_type):
          return value.encode(encoding)
  
      if six.PY3:
          return six.binary_type(str(value), encoding)  # For Python 3
      return six.binary_type(value)
docs: 将 values 转为 bytes，默认编码 utf-8
  
      :param value: 待转换的值
      :param encoding: 编码