print(f'Task {name} nothing to do') 中的f 含义?

print(f'Task {name} nothing to do')

{name} 表示一个name变量会替代进去。

f'Task {name} nothing to do'

这里的f 代表什么含义?
阅读 6.7k
3 个回答

python3.6的新特性,format的意思吧。
f'Task {name} nothing to do' 等价于 'Task {name} nothing to do'.format(name=name)

新手上路,请多包涵

意思是后面的字符串里有变量吧

其实就是格式化输出:

name = 5
print(f'{name}')
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题