2011-07-29 1 views

答えて

1

\ 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を変換するために、このような何かを行うことができますが
関連する問題