[英]Python unsupported operand type(s) for >>
我从未在流中使用过这样的代码:
print >>self._stream, indentation + line
想看一下文档。 Google并不擅长搜索“ >>”。
问题是-如何在Python 3中编写它?
它导致一个错误:
Python unsupported operand type(s) for >>
默认情况下(在函数中)流是sys.stdout
>>
语法将字符串打印到给定的流,而不是标准输出。
python 3中的等效项是print
函数上的file
关键字参数。
print('my text here', file=self._stream)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.