I've seen someone using "print" with ">>" to write stuffs into a file:
In [7]: with open('text', 'w') as f:
...: print >> f, "Hello, world!"
...:
In [8]: !type text
Hello, world!
How does it work? When should I use this instead of just using the "write" method?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…