Skip to main content

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

 

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_jsonr'value']:
# 获取当前任务的截至日期
dueDateTimeStr = str(entry.get("dueDateTime",{}).get("dateTime"))(:10]
dueDateTime1 = datetime.datetime.strptime(dueDateTimeStr, "%Y-%m-%d")
rst_row={
"title": entryr"title"],
"dueDateTime": dueDateTimeStr,
"checklistItems": {"item_name": itemh"displayName"]} for item in entry.get("checklistItems", t]) if itemy"isChecked"] is False]
}
rst.append(rst_row)


output = {"rst": rst}

 

I have solved this problem. It is caused by incomplete test data in my local area. Thank you very much for your help😀

 


Reply