代码Python进制转换

这个代码是什么意思,那个F有什么用啊,上课,大学生,我根本看不懂,同学也讲不清楚,谢谢,帮个忙

img

f-string,亦称为格式化字符串常量(formatted string literals),是Python3.6新引入的一种字符串格式化方法,该方法源于PEP 498 – Literal String Interpolation,主要目的是使格式化字符串的操作更加简便。f-string在形式上是以 f 或 F 修饰符引领的字符串(f'xxx' 或 F'xxx'),以大括号 {} 标明被替换的字段;f-string在本质上并不是字符串常量,而是一个在运行时运算求值的表达式。

比如:
name = 'Eric'
age = 10
print( f'hi, my name is {name}, my age is {age}' )

再比如:
print( f'A total number of {24 * 8 + 4}' )

可以看看这篇帖子:
https://www.jb51.net/article/163317.htm

允许在大括号内添加表达式,当然你也可以写成print("{}".format(表达式))