---
title: "python print'hello' File \"<stdin>\",line 1 print 'hello' SyntaxError:invalid syntax"
author: "hellbaby666"
date: "2013-07-01T10:31:00Z"
tags: []
slug: "python-print-hello-file-stdin-line-1-print-hello-syntaxerror-invalid-syntax"
draft: false
lastmod: "2013-07-09T09:23:06Z"
id: 1901725
url: "https://hellbaby666.iteye.com/blog/1901725"
---

python print'hello' File "&lt;stdin&gt;",line 1 print 'hello' SyntaxError:invalid syntax

刚开始看Python，照着书上些了个hello，结果错误：

&gt;&gt;&gt; print 'hello'  
&lt;wbr&gt;File "&lt;stdin&gt;", line 1&lt;br&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;print 'hello'&lt;br&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;&lt;wbr&gt;^&lt;br&gt; SyntaxError: invalid syntax&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;&lt;/wbr&gt;

&lt;wbr&gt;&lt;/wbr&gt;

查看3.0文档：[http://docs.python.org/release/3.0.1/whatsnew/3.0.html](http://docs.python.org/release/3.0.1/whatsnew/3.0.html)，发现从3.0开始print改成了

print()。文档是这样写的：The`print`statement has been replaced with a[`print()`](http://docs.python.org/release/3.0.1/library/functions.html#print "print")function, with keyword arguments to replace most of the special syntax of the old`print`statement ([**PEP 3105**](http://www.python.org/dev/peps/pep-3105)).

print语句被print()方法代替，旧print语句中的特定的语法被参数代替。

所以呢，hello world！应该写成这样：print ("hello world!")