本文整理匯總了Python中io.RawIOBase.write方法的典型用法代碼示例。如果您正苦於以下問題:Python RawIOBase.write方法的具體用法?Python RawIOBase.write怎麽用?Python RawIOBase.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.RawIOBase
的用法示例。
在下文中一共展示了RawIOBase.write方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wait_until_ready
# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import write [as 別名]
def wait_until_ready(self, channel:RawIOBase, timeout=60):
"""
sends ' ' (space) and waits for the corresponding ACK message. Once we have 3 of these in a row we can be fairly
certain the device is ready for ymodem.
:param channel:
:param timeout:
:return:
"""
success_count = 0
while channel.readline(): # flush any existing data
success_count = 0
while success_count < 2:
channel.write(b' ')
result = channel.read()
if result and result[0]==LightYModemProtocol.ack:
success_count += 1
示例2: bulk_copy
# 需要導入模塊: from io import RawIOBase [as 別名]
# 或者: from io.RawIOBase import write [as 別名]
def bulk_copy(read_from: io.RawIOBase, write_to: io.RawIOBase):
while True:
chunk = read_from.read(BUFFER_SIZE)
if not chunk:
break
write_to.write(chunk)