我想将f-string与我的string变量一起使用,而不是与使用字符串常量定义的string一起使用"..."。
这是我的代码
name=["deep","mahesh","nirbhay"]
user_input = r"certi_{element}" # this string i ask from user
for element in name:
print(f"{user_input}")
Run Code Online (Sandbox Code Playgroud)
此代码提供输出:
certi_{element}
certi_{element}
certi_{element}
Run Code Online (Sandbox Code Playgroud)
但我想要:
certi_{deep}
certi_{mahesh}
certi_{nirbhay}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?