【发布时间】:2021-11-30 04:32:54
【问题描述】:
所以我试图假设评分者定义了以下变量
a to be some int
b to be some float
s to be some string
编写一个程序,打印出以下内容,其中 中的值被变量内的实际值替换。但是,您只能使用 ONE print 语句。
// The variable 'a' has value of <a>. //
\\ While the variable 'b' has value of <b>. \\
// Lastly, the variable 's' has value of "<s>". //
例如,如果 a=1、b=1.5 和 s='hi',那么预期的输出是:
// The variable 'a' has value of 1. //
\\ While the variable 'b' has value of 1.5. \\
// Lastly, the variable 's' has value of "hi". /
这是我目前的代码,我是通过 Stack Overflow 用户的帮助获得的
def make_tags(tag, word):
print("<" + tag + ">" + word + "</" + tag + ">")
但是,当变量已经预先确定时,这不起作用......我应该改变什么??
【问题讨论】:
-
你想要的输出是什么,你得到的输出是什么?
-
真的完全不清楚你在问什么以及你描述的情况。你所说的“分级员”是什么意思?
-
使用
f-strings