Python输出函数print加上f的作用:即print(f" ")
主要作用就是格式化字符串,加f后可以在字符串里面使用用花括号括起来的变量和表达式,包含的{}表达式在程序运行时会被表达式的值代替。
例:
def greet_user(username):
print(f'hello, {username.title()}!')
greet_user('jesse')
输出结果:
hello, Jesse!
这里的title()函数表示的意思是返回’标题化‘的字符串,就是单词的开头为大写,其余为小写。