Python-仅在Linux终端中输入时发生EOF错误

问题描述

它可以在VS CODE终端上运行,但不能在linux终端上运行。错误:

File "/home/shaheer/start.py",line 10,in <module>
ques = input("Are you ready? (y/n)")
EOFError: EOF when reading a line

我的代码:

import os
import subprocess
from subprocess import Popen,PIPE,STDOUT
from subprocess import DEVNULL
import webbrowser
import time

time.sleep(10)

ques = input("Are you ready? (y/n)")
if ques == "y":
  print("Good!")
elif ques == "Y":
  print("Good!")
else:
  cmd = "pkill chrome"
  Popen([cmd],stderr=subprocess.DEVNULL,stdin=PIPE,shell=True)

我将其用作提醒脚本,以供长时间使用系统的人使用。

解决方法

[更新]现在正在工作,我不得不制作另一个.py文件并将其链接到该文件。 文件1(start.py):

const roles = this.reflector.getAllAndOverride(
  'roles',[
    context.getHandler(),context.getClass()
  ]
);

文件2(playsound.py):

import os
os.system("python3 /home/shaheer/playsound.py")

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...