Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 Python 套接字时使用 makefile() 的目的是什么?
我可以让一个程序只使用 Python 上的 send() 和 recv() 函数。但我读到最好使用 makefile() 方法来缓冲数据。我不明白这种关系和差异......有什么帮助吗?
谢!
makefile如果你觉得 Python 的文件接口方便,就可以使用。例如,您可以使用诸如readlineson 套接字之类的方法(使用时您必须手动实现它recv)。如果在套接字上发送文本数据,这会更方便,但是 YMMV。
makefile
readlines
recv