簡體   English   中英

pexpect 中的 send() 和 sendline() 有什么區別?

[英]What is the difference between send() and sendline() in pexpect?

我可以看到發送行有換行符。 但是,我無法理解child.send()何時使用? 誰能幫我理解或舉例說明child.send()child.sendline()之間的區別?

sendline()只是send()的一個方便包裝器。 如果您不想按 ENTER,則必須使用send()


以下來自我系統上的/usr/local/lib/python3.7/dist-packages/pexpect/pty_spawn.py

def sendline(self, s=''):
    '''Wraps send(), sending string ``s`` to child process, with
    ``os.linesep`` automatically appended. Returns number of bytes
    written.  Only a limited number of bytes may be sent for each
    line in the default terminal mode, see docstring of :meth:`send`.
    '''
    s = self._coerce_send_string(s)
    return self.send(s + self.linesep)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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