1
pexpect
をLinuxで使用している人はpexpect
がreadline()
機能を使用するときにウィンドウのスタイルの最後を返すことに気付いていますか?あなたはこれを取り除く方法を知っていますか?pexpect返されるウィンドウのスタイル最後の行
pexpect
をLinuxで使用している人はpexpect
がreadline()
機能を使用するときにウィンドウのスタイルの最後を返すことに気付いていますか?あなたはこれを取り除く方法を知っていますか?pexpect返されるウィンドウのスタイル最後の行
\ r \ nを返すreadline()だけでなく、pexpectによって返されるキャプチャされたテキストには\ r \ n行末が含まれています。
ドキュメント以下の説明があります。
readline(self, size=-1)
This reads and returns one entire line. A trailing newline is kept
in the string, but may be absent when a file ends with an incomplete
line. Note: This readline() looks for a \r\n pair even on UNIX
because this is what the pseudo tty device returns. So contrary to what
you may expect you will receive the newline as \r\n. An empty string
is returned when EOF is hit immediately. Currently, the size argument is
mostly ignored, so this behavior is not standard for a file-like
object. If size is 0 then an empty string is returned.
あなたは
line = child.readline()
line.replace('\r\n', '\n')
のn \に\ r \ nを変換するために、このような何かを行うことができますが