From the course: Python Standard Library Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

String interpolation

String interpolation - Python Tutorial

From the course: Python Standard Library Essential Training

Start my 1-month free trial

String interpolation

- [Instructor] Alright, lets pick up where we left off with the last example and take a look at string interpolation, and you need to have at least Python 3.6 for this to work. So lets open up our store format in the number six example, and you can see that this is where we left off in our previous example. So I'm going to import the datetime module because I'll need it for this example. I'm going to be formatting dates and times. And we'll learn more about dates and times later in the course. And once again, if we scroll down, you can see I have some variables here of different types. I've got a string, a floats, and I'm going to create a new variable to hold a date representing New Year's Eve. So I'll write nyd equals datetime. And don't worry about this for the moment if you aren't familiar with constructing datetimes. We'll get to this later. So going to write 2019, one and one. So that's January 1st, that's New Year's Day. String interpolation works by placing a lower case "f"…

Contents