What does "f" character in front of the string mean?

Quantum_07 report abuse

I noticed that sometimes strings in python have an "f" symbol in front of them. Also, they have some values in "{}".

For example: f'directory/{filename}'.

So what are those strings?

Answers

Lu-at-Imaginghub report abuse

Hello @Quantum_07

They are known as "f-string" and used to format strings in python. They were added in 3.6 and the syntax is:

f'some text {var1} more text {var2}', where 'var1' and 'var2' are previously defined variables. 

As you can see the syntax is very compact and user-friendly.

Best regards, Lu

Add Answer

Need support?

Just drop us an email to ... Show more