1. 程式人生 > >SyntaxError: Missing parentheses in call to 'print'. Did you mean print('xxxxx')?

SyntaxError: Missing parentheses in call to 'print'. Did you mean print('xxxxx')?

Python2.x與3​​.x的區別之“print”
正如錯誤提醒的那樣:
Missing parentheses in call to ‘print’. Did you mean print(‘xxxxx’);
在Python3.x之中print語句沒有了,取而代之的是print()函式。

#!/usr/bin/python
# -*- coding: UTF-8 -*-
flag = False
name = 'lin'
if name == 'python':
    flag = True
    print ('hello world')
else:
    print
(name)

注: Python 2.6與Python 2.7部分地支援這種形式的print語法。