String formatting is weird in Python, but rumor has it that Python 3000 will break backwards compatibility and fix that. Currently (Python 2.5) you do this
Incidentally, python has no 'num2str' like matlab, so this is how you do it
x = 'Rabindranath Tagore'Weird, ain't it?
y = 1861
z = 80.25
print '%s was born in %d and lived %2.2f years' %(x,y,z)
Incidentally, python has no 'num2str' like matlab, so this is how you do it
You can also write
ReplyDeleteprint x,"was born in",y,"and lived", z,"years"