繁体   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