خرید بک لینک

Vote count: 0

I have a string which looks like:

dt_string='some_prefix/%Y-%m-%d/%H:%M/some_postfix'

I want to format this string with current date and time, so that it may look like 'some_prefix/2016-06-28/10:00/some_postfix'

But my problem is that the date pattes may not always be in %Y-%m-%d/%H:%M. It can be anything like %m-%d-%Y/%H:%M. I looked into datetime.datetime.strptime but it takes format as input. In my case, the format isn't fixed. Is there a function that can determine the date time format dynamically from the input string? Or shall I write a logic determine format, and then use datetime.datetime.strptime ?

asked 29 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 9 تير 1395 ساعت: 0:36

صفحه بندی