replace()不接受关键字参数



我正试图在python 中找到每月的第一天

<form method="GET" action="">
<input name="range2" type="date"/>
<input type="submit"/>
</form>
to_date = request.GET.get('range2')    
from_date = to_date.replace(day=1)

但我得到了这个错误:replace((不接受关键字参数

to_date是什么类型?执行print(type(to_date))-如果它是str,它将使用str.replace,它不需要kwargs。这将在此处引发错误。:(

最新更新