0
def recv():

while True:
    data = udp_socket.recvfrom(1024)
    content, address = data
    ip, port = address
    print('\r>>>[%s %d] %s' % (ip, port, content.decode()))
    print('<<<', end='')

When I call this function, the content in the last print function (the last line of codes) is not printed out. Anybody knows why? Thank you!

Jerence
  • 97
  • 1
  • 9

1 Answers1

0

The standard output stream is buffered so it is likely that the <<< is in the buffer and would be flushed the next time that a newline is written. Try removing the end=''. You can also switch to using sys.stderr which (I believe) is unbuffered.

D.Shawley
  • 58,213
  • 10
  • 98
  • 113