Python 错误:io.UnsupportedOperation:fileno [英] Python Error: io.UnsupportedOperation: fileno
问题描述
我正在使用此链接中的服务器和客户端程序:http://www.bogotobogo.com/python/python_network_programming_tcp_server_client_chat_server_chat_client_select.php
I am using a server and the client programs from this link: http://www.bogotobogo.com/python/python_network_programming_tcp_server_client_chat_server_chat_client_select.php
当我运行客户端时遇到以下错误:
When I run the client I encounter the following error:
Traceback (most recent call last):
File "client.py", line 26, in client
read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
io.UnsupportedOperation: fileno
我使用的是 Python 3
,但是我已经使用 print 从 Python 2 到 3
更改了所有行.
I am using Python 3
, but I have changed all lines using print from Python 2 to 3
.
代码如下:
while 1:
socket_list = [sys.stdin, s]
# Get the list sockets which are readable
read_sockets, write_sockets, error_sockets = select.select(socket_list , [], [])
推荐答案
虽然 fileno()
方法适用于普通 IO 对象(sys.stdout
, sys.stderr
、sys.stdin
和 socket.socket
),IDLE Python IDE 会更改您的 IO 对象,从而破坏了这一点.
While the fileno()
method works on normal IO objects (sys.stdout
, sys.stderr
, sys.stdin
and socket.socket
), the IDLE Python IDE changes your IO objects which breaks this.
所以...如果您收到此错误,请改为直接从 Python 运行命令.
So... if you get this error, run the command from straight up Python instead.
这篇关于Python 错误:io.UnsupportedOperation:fileno的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!