Knowee
Questions
Features
Study Tools

We want to convert the below string in date-time value:import timestr = '21/01/2017'datetime_value = time.strptime(str,date_format)To convert the above string, what should be written in place of date_format?“%d/%m/%y”“%D/%M/%Y”“%d/%M/%y”“%d/%m/%Y”

Question

We want to convert the below string in date-time value:import timestr = '21/01/2017'datetime_value = time.strptime(str,date_format)To convert the above string, what should be written in place of date_format?“%d/%m/%y”“%D/%M/%Y”“%d/%M/%y”“%d/%m/%Y”

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct format to convert the string '21/01/2017' to a datetime value would be "%d/%m/%Y". This is because:

  • %d is used for day of the month as a zero-padded decimal number (01, 02, ..., 31).
  • %m is used for month as a zero-padded decimal number (01, 02, ..., 12).
  • %Y is used for year with century as a decimal number (0001, 0002, ..., 2013, 2014, ..., 9998, 9999).

So, the correct answer is “%d/%m/%Y”.

This problem has been solved

Similar Questions

To convert the above string, what should be written in place of date_format?“%d/%m/%y”“%D/%M/%Y”“%d/%M/%y”“%d/%m/%Y”

How to convert Date object to String?

Test time left: 47:16 Choose the Correct Answer(s) What does the following statements do? from datetime import * print(datetime.today().strftime('%B')) Options Displays the full weekday name Displays the full month name Displays the abbreviated day name Displays the abbreviated month name

e correct answerWhat will be the output of the following Python code snippet?print('{:,}'.format('0987654321'))

Write a Python program that converts seconds into days, hours, minutes, and seconds.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.