Python: How to get input from console while an infinite loop is running?

后端 未结 3 1481
自闭症患者
自闭症患者 2020-12-03 12:52

I\'m trying to write a simple Python IRC client. So far I can read data, and I can send data back to the client if it automated. I\'m getting the data in a while True<

3条回答
  •  旧时难觅i
    2020-12-03 13:08

    You can use a async library (see answer of schlenk) or use https://docs.python.org/2/library/select.html

    This module provides access to the select() and poll() functions available in most operating systems, epoll() available on Linux 2.5+ and kqueue() available on most BSD. Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on Unix, it works on pipes). It cannot be used on regular files to determine whether a file has grown since it was last read.

提交回复
热议问题