print
does things file.write
doesn't, allowing you to skip string formatting for some basic things.
It inserts spaces between arguments and appends the line terminator.
print "a", "b" # prints something like "a b
"
It calls the __str__
or __repr__
special methods of an object to convert it to a string.
print 1 # prints something like "1
"
You would have to manually do these things if you used file.write
instead of print
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…