[英]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.