我有以下代码:
age = raw_input("How old are you? ")
height = raw_input("How tall are you? ")
weight = raw_input("How much do you weigh? ")
print " So, you're %r old, %r tall and %r heavy." %(age, height, weight)
好的,所以该raw_input
函数可以在没有尾随换行符的情况下进行标准输出。然后该函数从输入中读取一行,将其转换为字符串(去除尾随的换行符),然后返回。
我不明白为什么每个提示消息都显示在新行上,因为 raw_input 只返回一个字符串。它没有添加换行符,我\n
的代码中也没有。