Python 使用input()时获取EOFError?
我的剧本是出于某种原因而写的?我正在为帮助台制作一个消息传递系统的脚本,因为我想用我的主程序live帮助人们解决他们的问题。我刚刚完成最后的润色,突然间输入不再有效,而不会给我带来EOF错误??这是我的密码。它在生成消息发送gui之前请求一个名称,同时进入while循环,以绿色开头的用户名打印发送的消息Python 使用input()时获取EOFError?,python,Python,我的剧本是出于某种原因而写的?我正在为帮助台制作一个消息传递系统的脚本,因为我想用我的主程序live帮助人们解决他们的问题。我刚刚完成最后的润色,突然间输入不再有效,而不会给我带来EOF错误??这是我的密码。它在生成消息发送gui之前请求一个名称,同时进入while循环,以绿色开头的用户名打印发送的消息 from sendgui import * import sys from multiprocessing import Process from termcolor import colore
from sendgui import *
import sys
from multiprocessing import Process
from termcolor import colored
import socket
def initinite():
name = input("username: ")
msgsendr(name)
if __name__ == "__main__":
proc = Process(target=initinite)
proc.start()
ClientSocket = socket.socket()
host = socket.gethostname()
port = 8080
print(colored('Waiting for connection', 'yellow'))
try:
ClientSocket.connect((host, 8080))
except socket.error as e:
print(colored("ERROR!", "red"), colored("could not connect. the server may be offline or you don't have an internet connection", "yellow"))
input("press enter to continue")
sys.exit("could not connect")
print(colored("connected!", "green"))
while True:
Response = ClientSocket.recv(1024)
Response = Response.decode()
name = Response.split(": ")[0]
mess = Response.split(": ")[1]
name = colored(name, "green")
print(name+": "+mess)
ClientSocket.close()
有人要求进行全面追踪,因此:
Process Process-1:
Traceback (most recent call last):
File "C:\Users\*redacted*\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "C:\Users\*redacted*\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\*redacted*\Desktop\e program files\recievegui.py", line 7, in initinite
name = input("username: ")
EOFError: EOF when reading a line
请发布完整的回溯。好的。谢谢你告诉我!完成!希望这有帮助!您是否从类似VSCode的IDE运行脚本?默认情况下,它们不允许您提供输入。我使用的是pycharm,它带有一个终端,可以打开它而不是ide,因为输入可以在其他程序上工作。请发布完整的回溯。ok就可以了。谢谢你告诉我!完成!希望这有帮助!您是否从类似VSCode的IDE运行脚本?默认情况下,它们不允许您提供输入。我使用的是pycharm,它带有一个终端,可以打开它而不是ide,因为输入可以在其他程序上工作