簡體   English   中英

Python不受支持的>>的操作數類型

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM