Formatting date objects into strings Part - 2

Lesson Details:
June 29, 2020


I: Introduction

A: Learn basic python programming for beginners

Briefly describe the content of the article in the introduction.

II: Body

A: Formatting date objects into strings part - 2

Describe the content of the body of the article.

III: Conclusion

A: What we learned and how it is important in the wider context of the language

B: The future of programming languages in general and python in specific

Now let's see how our article looks like:

Introduction: Briefly describe the content of the article in the introduction. Args: Describes format() method that uses strftime() function to display date objects into strings. It also describes that how to pass format specifiers as parameters to strftime function. >>> import time >>> dt = datetime(2017,1,10,8,0) >>> print(dt) 2017-01-10 08:00:00 Now let's try to convert this object into string using format() method. This method uses strftime() function to display date objects into strings. It also describes that how to pass format specifiers as parameters to strftime function. >>> dt_str=dt.format("%Y-%m-%d %H:%M") '2017-01-10 08:00:00' And here is the output on terminal >>> print(dt_str) 2017-01-10 08:00:00 Formatting date objects into strings part - 2 Args : First line of code shows how to convert datetime objects into strings using format() method. Second line of code demonstrates how to specify custom format specifier for format() method. Let's check the output on terminal >>> dt_str=dt.format("%Y-%m-%d %H:%M") '2017-01-10 08:00:00' >>> dt_str2="{0} {1} {2}".format(dt, "ISO", "{3}") '2017-01-10 08:00:00 ISO 2017' And here is the output on terminal >>> print(dt_str2) 2017-01-10 08:00:00 ISO 2017 Conclusion A : What we learned and how it is important in the wider context of the language Args : Start with a few lines about what you learned from the exercise and how it fits into the wider context (e.g., what you're learning this quarter). B : The future of programming languages in general and python in specific Args : By now, you should have enough knowledge about Python programming language. You can use your knowledge to create programs that run on your computer or other computers on internet. You can easily share your program with other people by publishing them on the web. If you are interested, try some of these exercises below to learn more about Python programming language. Top 10 Open Source Projects Written in Python Top 5 Python Libraries for Data Science 10 Best Python IDE & Code Editor Comparison

And finally our article looks like this:

loader
Course content