Python 的print报错SyntaxError: invalid syntax

1、

1 #!/usr/bin/python
2 print "hello world!"

print报错:SyntaxError: Missing parentheses in call to 'print'

将打印字符加括号后不报错

1 #!/usr/bin/python
2 print("hello world!")

2、print type

1 #!/usr/bin/python
2 a = "smg"
3 print type(a)

type报错:

print type(a)
            ^
SyntaxError: invalid syntax

type函数括号后不报错

1 #!/usr/bin/python
2 a = "smg"
3 print( type(a) )

运行结果是:<class 'str'>

 

posted on 2016-04-21 15:43  小金鱼的笔记  阅读(2293)  评论(0编辑  收藏  举报