如何摆脱 Python raw_input() 中的正斜杠
这里是初学者程序员。所以请耐心听我说。我有一个简单的 python 程序。
print "How tall are you?",
height = raw_input()
print "So you're %r tall" %(height)
如果我输入高度为 6'6'' python 将输出
So you're '6\6"'
如何从输出中删除正斜杠“\”?
提前致谢!
Beginner programmer here. So bear with me. I have a simple python program.
print "How tall are you?",
height = raw_input()
print "So you're %r tall" %(height)
If I enter the height as 6'6'' python would output
So you're '6\6"'
How do I get rid of the forward slash "\" from the output?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
%r
转换为高度的表示,你应该使用%s
代替如果你使用的是 Python >=2.6,你可以这样写
%r
converts to the repr of height, you should use%s
insteadIf you are using Python >=2.6, you can write it this way instead