tất cả các ký tự trong một chuỗi có thể được hiểu như là một biểu hiện điều hành thường xuyên sử dụng này nếu bạn có một chuỗi dài với rất nhiều các ký tự đặc biệt và bạn muốn tránh gõ một rất nhiều những dấu xồ nguợc, hoặc nếu bạn nhận được một chuỗi từ một người sử dụng (đối với | 316 CHAPTER 14 NETWORK PROGRAMMING host port 1234 host port fdmap s 5 p s while True events for fd event in events if fd in fdmap c addr print Got connection from addr c fdmap c elif event data fdmap fd .recv 1024 if not data No data -- connection closed print fdmap fd .getpeername disconnected fd del fdmap fd else print data You can find more information about select and poll in the Python Library Reference http doc lib . Also reading the source code of the standard library modules asyncore and asynchat found in the and files in your Python installation can be enlightening. Twisted Twisted from Twisted Matrix Laboratories http is an event-driven networking framework for Python originally developed for network games but now used by all kinds of network software. In Twisted you implement event handlers much like you would in a GUI toolkit see Chapter 12 . In fact Twisted works quite nicely together with several common GUI toolkits Tk GTK Qt and wxWidgets . In this section I ll cover some of the basic concepts and show you how to do some relatively simple network programming using Twisted. Once you grasp the basic concepts you can check out the Twisted documentation available on the Twisted web site along with quite a bit of other information to do some more serious network programming. Twisted is a very rich framework and supports among other things web servers and clients SSH2 SMTP POP3 IMAP4 AIM ICQ IRC MSN Jabber NNTP DNS and more CHAPTER 14 NETWORK PROGRAMMING 317 Downloading and Installing Twisted Installing Twisted is quite easy. First go to the Twisted Matrix web site http and from there follow one of the download links. If you re using Windows download the Windows installer for your version of Python. If you re using some other system .