2019-06-25 08:21:36 +00:00
|
|
|
def str_to_bytes(data):
|
2019-06-26 20:13:36 +00:00
|
|
|
'''Converts a string to bytes with .encode()'''
|
2019-06-25 08:21:36 +00:00
|
|
|
try:
|
2019-06-26 20:13:36 +00:00
|
|
|
data = data.encode('UTF-8')
|
2019-06-25 08:21:36 +00:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
return data
|
|
|
|
|
|
|
|
def bytes_to_str(data):
|
|
|
|
try:
|
2019-06-26 20:13:36 +00:00
|
|
|
data = data.decode('UTF-8')
|
2019-06-25 08:21:36 +00:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
return data
|