我是Python编程的新手,我正在尝试创建一个服务器和一个客户端.我仍然希望能够从键盘输入内容,这样我就可以通过输入'exit'来关闭服务器上的服务器.我从各个站点获取了示例代码,以便在套接字编程和此代码中找到我所处的位置.
但是,每当我运行代码时,我都会收到以下错误消息:
The host name of this machine is 127.0.0.1
The IP address of the host is 127.0.0.1
Server now awaiting client connection on port 2836
im right before the select
Traceback (most recent call last):
File "/root/Server_2.py", line 42, in <module>
inputready, outputready, exceptready = select.select(input, [], [])
TypeError: argument must be an int, or have a fileno() method.
>>>
Run Code Online (Sandbox Code Playgroud)
我正在阅读那个传递这个(在Windows中)是删除sys.stdin因为Windows只接受套接字.我正在尝试在Linux中编写此代码.我已经尝试了各种各样的事情来尝试让它发挥作用,而我完全没有资源和想法来尝试.以下是服务器代码:
import socket #import socket module
import select
import sys
host = "127.0.0.1"
print ("The host name of this …Run Code Online (Sandbox Code Playgroud)