The following code is giving me:
Runtime.MarshalError: Unable to marshal response: {'Yes'} is not JSON serializable
from calendar import monthrange
def time_remaining_less_than_fourteen(year, month, day):
a_year = int(input['year'])
b_month = int(input['month'])
c_day = int(input['day'])
days_in_month = monthrange(int(a_year), int(b_month))[1]
time_remaining = ""
if (days_in_month - c_day) < 14:
time_remaining = "No"
return time_remaining
else:
time_remaining = "Yes"
return time_remaining
output = {time_remaining_less_than_fourteen((input['year']), (input['month']), (input['day']))}
#print(output)
When I remove {...} it then throws: 'unicode' object has no attribute 'copy'
bytes
as the record's data. Conversion tostr
didn't even cross my mind. Quick suggestion:base64.b64encode(payload).decode("utf-8")
could be simplybase64.b64encode(payload).decode()
. Base64 data is, by definition, ASCII. ASCII itself is UTF-8, which is the default value for the encoding parameter in Python 3. Specifying the codec there is just redundant. – Locale