求助,print的用法。。。

求助,print的用法。。。



[Copy to clipboard] [ - ]
CODE:
>>> for x in range(3):
...     print x
...
0
1
2
>>> for x in range(3):
...     print x,
...
0 1 2

怎么print出来
012
?,我不想里面有空格,谢谢


[Copy to clipboard] [ - ]
CODE:
>>> import sys
>>> def no_space_before(x):
...     sys.stdout.softspace = 0
...     return x
...
>>> for x in range(3):
...     print no_space_before(x),
...
012

自己解决了。。。
>>>import sys
>>>for x in range(3):
...     sys.stdout.softspace = 0
...     print x,
...
012
>>>for x in range(3):
...     sys.stdout.write(str(x))
... print
...
012
>>>out=""
>>>for x in range(3):
...     out += str(x)
... print out
...
012