code: def to_bytes(s, encoding="utf-8"):
      
      if isinstance(s, six.binary_type):
          return s
      if six.PY3:
          return bytes(s, encoding)
      return s.encode(encoding)
docs: Convert a string to bytes.