python 3 中对print的改动

开始学习python,直接从python3开始学习了,虽然相应的库和资料还比较少,据说python3是一次大改动吧。看了一些python2.x的资料,在python3 shell中实现的时候,发现python3中对print函数做了较大的修改:

 

>>> help('''print''')
Help on built
-in function print in module builtins:

print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout)

Prints the values to a stream,
or to sys.stdout by default.
Optional keyword arguments:
file: a file
-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.

最简单的,在python2.x中,可以使用print 'this is a string'这种用法,但在python3中就不行了。这看起像是在python2中,print是个关键字什么的,还不算是函数,而到了python3中,print变成了build-in函数?

posted @ 2010-08-12 22:53  I'm 农民工  阅读(2533)  评论(0编辑  收藏  举报