简体   繁体   中英

replace() takes no keyword arguments

I'm trying to find the first day of the month in 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)

but i got this error : replace() takes no keyword arguments

What type is to_date ? Do print(type(to_date)) - if its a str , it is going to use str.replace, which takes no kwargs. This would throw an error here. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM