How to get part of string and pass it to other function in python?

前端 未结 4 464
一整个雨季
一整个雨季 2021-01-28 06:58

My task is to verify whether string is valid date and time or not.

\"2013-01-01W23:01:01\"

The date and the time are separated with

4条回答
  •  既然无缘
    2021-01-28 07:24

    You can try this ,

    >>> a="2013-01-01W23:01:01"
    >>> a.split('W')
    ['2013-01-01', '23:01:01']
    

    And then send a.split('W')[0] and a.split('W')[1] to the validation functions.

提交回复
热议问题