for i in range(10):
x = 0.1*i
print x
print x/(1-x*x)
我试图用for循环打印结果,但它说Syntax Error: Missing parentheses in call to 'print'
。Python for循环打印错误
我使用的Python 3.4,我是新来的Python。
for i in range(10):
x = 0.1*i
print x
print x/(1-x*x)
我试图用for循环打印结果,但它说Syntax Error: Missing parentheses in call to 'print'
。Python for循环打印错误
我使用的Python 3.4,我是新来的Python。
错误信息很清楚,不是吗?你print
function缺少所需的函数调用括号:
print(x)
Python 2有一个print
声明在句法print x
是正确的; Python 3已经改变了这一点。您应该从Python 3特定资源中学习Python,例如Python tutorial。
用于打印语句的语法在2.X中有效,但在3.X版本中已更改。您需要在您的打印语句周围使用parentheses,例如:
print (x/(1-x*x))
'print x'是python 2语法。 – SSC 2014-12-06 06:39:27
https://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function – 2014-12-06 06:40:37