My python code runs normally locally, but it fails when I put it in code component. I am now using a for loop to convert one of the date items from a string to a date, and then compare the size with the current date, but now it fails. The code component prompts me that the parameter passed in [datetime.datetime.strptime(dueDateTimeStr, "%Y-%m-%d")] is None
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/e4a77c96-037f-49c3-9a4d-03314f457c58.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/b05cc04a-1e52-4f08-9b3b-ce79e1f2ba37.png)
Can you help me see why it fails? Or code component is not applicable to string conversion date
Full Code
import json
import datetime
# Get the input JSON string
res_body = input_data.get('value', '{}')
res_body_json = json.loads(res_body)
rst=[]
#获取当天日期
now_date_str = datetime.date.today().strftime('%Y-%m-%d')
now_date = datetime.datetime.strptime(now_date_str, "%Y-%m-%d")
for entry in res_body_json['value']:
# 获取当前任务的截至日期
dueDateTimeStr = str(entry.get("dueDateTime",{}).get("dateTime"))[:10]
dueDateTime1 = datetime.datetime.strptime(dueDateTimeStr, "%Y-%m-%d")
rst_row={
"title": entry["title"],
"dueDateTime": dueDateTimeStr,
"checklistItems": [{"item_name": item["displayName"]} for item in entry.get("checklistItems", []) if item["isChecked"] is False]
}
rst.append(rst_row)
output = {"rst": rst}