我在一个项目中发现了这段代码,我不知道>>
是做什么的。有人解释吗?你知道吗
def save(self, fpath=None):
"""
Save the JSON data to fpath. This is done automatically if the
game is over.
"""
if fpath is None:
fpath = _jsonf % self.eid
try:
print >> gzip.open(fpath, 'w+'), self.rawData,
except IOError:
print >> sys.stderr, "Could not cache JSON data. Please " \
"make '%s' writable." \
% os.path.dirname(fpath)
我知道这段代码是从模块中的其他文件和对象获取信息的,我也知道代码的总体工作原理。只有print >>
让我困惑。当这个模块安装在没有写访问权限的目录中时,会出现消息Could not cache...
。整个文件位于here,但我怀疑它是否有用。你知道吗
>>
打印到类似文件的对象^{}
在本例中,它将错误消息打印到
stderr
相关问题 更多 >
编程相关推荐