Py学习  »  Python

python输入法

Ayat Al-shahriar Mahin • 4 年前 • 184 次点击  

我试着按照书中的说明执行下面的代码,但是ide显示了括号错误和语法错误代码如下所示。

print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % (
age, height, weight)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/48714
 
184 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Oleg Kalachev
Reply   •   1 楼
Oleg Kalachev    4 年前

您的示例是Python 2,它是Python的旧版本可能你用的是版本3。python 3的变体是:

print("How old are you?", end=' ')
age = input()
print("How tall are you?", end=' ')
height = input()
print("How much do you weigh?", end=' ')
weight = input()
print("So, you're %r old, %r tall and %r heavy." % (age, height, weight))