当前位置:网站首页>What does it mean to prefix a string with F?

What does it mean to prefix a string with F?

2022-07-07 22:23:00 Happy learning Python

Today's learning class , Find the following expression :

msg = f"{self.name} serves wonderful {self.cuisine_type}."
print(f"\n{msg}")
# Precede string with f, Is to allow adding pytho expression , Of the above cases "self.name" It's not a string , It's a variable .
Let's take a simple example :
Run the following program
Output is :
str1 The output is zero 1+1=2
str2 The output is zero 2=2

原网站

版权声明
本文为[Happy learning Python]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130606000598.html