TypeError: strptime() takes exactly 2 arguments (1 given)

计算从开始日期到结束日期范围内的所有日期,报错TypeError: strptime() takes exactly 2 arguments (1 given)

img

Python time strptime() 函数根据指定的格式把一个时间字符串解析为时间元组。

img


看到这个语法了吗?,其中可以省略的参数是格式化参数format,时间字符串是不可省略的,你的代码里没写时间字符串,只写了要格式化的format。

有帮助的话采纳一下哦!

strptime 需要两个参数,你只给了一个,例如
t = time.strptime(t, "%Y-%m-%d %H:%M:%S")