f-string怎么格式转化

2024-10-13 05:49:56

1、animal = "dog"print(f"There is a {animal}.")基本的格式就是f后面街上字符串,然后用大括号括如变量。

f-string怎么格式转化

3、lucky = 88print(f"The lucky number is {lucky + 12}.")实际上只要语法不出错,这个大括号里面是可以进行运算的。

f-string怎么格式转化

5、print(f"The lucky number is {{666}}.")如果需要输出大括号,那么我们需要再加一个大括号。

f-string怎么格式转化
猜你喜欢