【发布时间】:2017-11-29 03:30:40
【问题描述】:
如何将经典字符串转换为 f 字符串?
variable = 42
user_input = "The answer is {variable}"
print(user_input)
输出:The answer is {variable}
f_user_input = # Here the operation to go from a string to an f-string
print(f_user_input)
所需输出:The answer is 42
【问题讨论】:
标签: python python-3.x string-interpolation f-string