我建立了一種壓光機的Web應用程序的在Python中,如何檢查日期是否有效?
我已經建立了以HTML格式如下
<form action='/event' method='post'>
Year ("yyyy"): <input type='text' name='year' />
Month ("mm"): <input type='text' name='month' />
Day ("dd"): <input type='text' name='day' />
Hour ("hh"): <input type='text' name='hour' />
Description: <input type='text' name='info' />
<input type='submit' name='submit' value='Submit'/>
</form>
來自用戶的輸入,然後在一個CherryPy的服務器submited
我想知道,有沒有辦法檢查用戶輸入的日期是否是有效日期?
顯然我可以寫很多的if語句,但是有沒有內置的函數可以檢查這個?
感謝
相關:[我如何驗證python中的日期字符串格式?](http://stackoverflow.com/q/16870663) – kenorb 2015-07-27 20:35:15