pthon3.3...print,出錯的問題。。。。

剛開始學python,跟這書上打個hello world  結果出錯了。。。。快哭了

python 

print'hello'

File "<stdin>",line 1 print 'hello' SyntaxError:invalid syntax


>>> print 'hello'
  File "<stdin>", line 1
    print 'hello'
                ^

SyntaxError: invalid syntax

print(*objectssep=' 'end='\n'file=sys.stdoutflush=False)

Print objects to the stream file, separated by sep and followed by endsepend and file, if present, must be given as keyword arguments.

All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep andend must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.

The file argument must be an object with a write(string) method; if it is not present or Nonesys.stdout will be used. Whether output is buffered is usually determined by file, but if the flush keyword argument is true, the stream is forcibly flushed.

Changed in version 3.3: Added the flush keyword argument.

原來,print語句在3.0後已經被換成和print()函數,具體用法見上方的官方說明

 查看3.0文檔:http://docs.python.org/release/3.0.1/whatsnew/3.0.html
print()。文檔是這樣寫的:The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105).
print語句被print()方法代替,舊print語句中的特定的語法被參數代替。
所以呢,hello world!應該寫成這樣:print ("hello world!")



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章