Пример #1
0
 def _all_to_bytes(message):
     """
     Convert an int/float/str to bytes, e.g., 1.65 -> b'1.65', 'hello -> b'hello'
     :param message: int/float/str
     :return: -1 if type error, otherwise str
     """
     if type(message) == int or type(message) == float:
         return conversion.str_to_bytes(str(message))
     elif type(message) == str:
         return conversion.str_to_bytes(message)
     else:
         return -1
Пример #2
0
 def _all_to_bytes(message):
     """
     Convert an int/float/str to bytes, e.g., 1.65 -> b'1.65', 'hello -> b'hello'
     :param message: int/float/str
     :return: -1 if type error, otherwise str
     """
     if isinstance(message, int) or isinstance(message, float):
         return conversion.str_to_bytes(str(message))
     elif isinstance(message, str):
         return conversion.str_to_bytes(message)
     else:
         return -1