1

初级程序员在这里。所以请耐心等待。我有一个简单的 python 程序。

print "How tall are you?",
height = raw_input()

print "So you're %r tall" %(height)

如果我输入高度为 6'6'' python 会输出

所以你是 '6\6"'

如何摆脱输出中的正斜杠“\”?

提前致谢!

4

1 回答 1

7

%r转换为高度的 repr,您应该%s改用

如果你使用 Python >=2.6,你可以这样写

print "So you're {height} tall.".format(height=height)
于 2011-04-21T02:55:22.323 回答