【问题标题】:What is the difference between send() and sendline() in pexpect?pexpect 中的 send() 和 sendline() 有什么区别?
【发布时间】:2021-04-07 04:32:41
【问题描述】:

我是 pygtk 的新手,因此我有这个问题。 使用 Pygtk 在窗口中单击按钮时,如何在 Gui 窗口而不是控制台上打印结果。 请帮帮我!

【问题讨论】:

    标签: python automated-tests pygtk


    【解决方案1】:

    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)
    

    【讨论】:

      猜你喜欢
      • 2022-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 1970-01-01
      • 2013-02-25
      • 2010-12-19
      相关资源
      最近更新 更多