相关疑难解决方法(0)

将字符串转换为f-string

如何将经典string转换为f-string?:

variable = 42
user_input = "The answer is {variable}"
print(user_input)
Run Code Online (Sandbox Code Playgroud)

答案是{变量}

f_user_input = # Here the operation to go from a string to an f-string
print(f_user_input)
Run Code Online (Sandbox Code Playgroud)

答案是42

python string-interpolation python-3.6

9
推荐指数
4
解决办法
4069
查看次数

标签 统计

python ×1

python-3.6 ×1

string-interpolation ×1