Python won't compare strings -
i have python script listening on socket.
code looks this:
def clientthread(conn): while true: data = conn.recv(1024) if data == 'quit':
i'm connected server using telnet. when sent quit, code after "if data == 'quit':" doesn't execute. wrong?
most work of time if remove line break.
but: if want sort of reliability can't take output of recv , compare command. os might split data in way want's more or less parts. 'qu' , 'it\n' separately. need buffer return of recv , use example startswith match next command , remove executed commands.
also colonel thirty 2 said in comment if useing python 3.x byte strings need compare byte string b"quit"
Comments
Post a Comment