我想将 f-string 与我的字符串变量一起使用,而不是使用字符串文字定义的字符串,"...".
这是我的代码:
name=["deep","mahesh","nirbhay"]
user_input = r"certi_{element}" # this string I ask from user
for element in name:
print(f"{user_input}")
此代码提供输出:
certi_{element}
certi_{element}
certi_{element}
但我想要:
certi_{deep}
certi_{mahesh}
certi_{nirbhay}
我怎样才能做到这一点?
慕虎7371278
湖上湖
ibeautiful
相关分类