右移运算符如何在python打印语句中工作? [英] How does the right-shift operator work in a python print statement?
本文介绍了右移运算符如何在python打印语句中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我见过有人使用带有">>"的打印"来将内容写入文件:
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?
推荐答案
查看全文