shiftlist = {'fn': key, 'begin': begintime, 'end': endtime}
ag = requests.get(URlshiftlist, headers=ST, params=shiftlist)
string = json.loads(ag.text)
title = string['records']
a = [item['closeDateTime'] for item in title]
print(a)
并且可能包含:
a = [2018-02-03T15:02:57]
a = [None]
a = []
if a:
URL = tlgrm
msg = {'chat_id': 0000, 'text': '✅ ' + value + ' | Bla'}
r = requests.post(URL, data=msg)
if not a:
URL = tlgrm
msg = {'chat_id': 0000, 'text': 'ℹ️ ' + value + ' | Bla bla'}
r = requests.post(URL, data=msg)
if a:当 a = [2018-02-03T15:02:57] 和 a = [None] 时作出反应
如何使 if a:仅在 a = [2018-02-03T15:02:57] 时做出反应?
表示容器及其第一个元素不为空的条件:
None如果您的情况允许空字符串,那么您可以明确比较:如果只允许具有指定格式的日期的字符串: