#1.
def month_scope(start=None):
if start is None:
raise ValueError(‘start is null’)
ingore_var, daysOfMonth = calendar.monthrange(start.year,start.month)
firstdayOfNextMonth=start+timedelta(days=(daysOfMonth-start.day+1))
return firstdayOfNextMonth
# it is used calculate next month first day
#2.
datetime.strptime(“20180501”, ‘%Y%m%d’)
datetime.strftime(“20180501”, ‘%Y%m%d)
note: strptime will produce date format which include hour, min,second
strftime will produce date format which only include year, month,day
import json
data1 = {‘b’: 789, ‘c’: 456, ‘a’: 123}
encode_json = json.dumps(data1)
print type(encode_json), encode_json
decode_json = json.loads(encode_json)
print type(decode_json)
print decode_json[‘a’]
print decode_json