utils.py 209 B

1234567891011
  1. import six
  2. __all__ = ('str_to_bytes', )
  3. def str_to_bytes(value):
  4. """Simply convert a string type to bytes."""
  5. if isinstance(value, six.string_types):
  6. return value.encode()
  7. return value