2012年8月29日 星期三

Printing Without Space or NewLine

A trick of printing thing
--------------------------------------------------------
print "hello"
print "world"

The statement above print out something like this:

hello
world

Then by using comma,


print "hello",
print "world"

It will print:

hello world

The cool part is this: 

import sys
sys.stdout.write("hello")
sys.stdout.write("world")

By doing this, It will finally print out:

helloworld


From...http://codingrecipes.com/

沒有留言:

張貼留言