Python - 仅在 Linux 终端输入时出现 EOF 错误
Python - EOF error on input only in Linux terminal
它在 VS CODE 终端中工作,但在 linux terminal.ERROR:
中不工作
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 文件并 link 到这个文件。
文件 1 (start.py):
import os
os.system("python3 /home/shaheer/playsound.py")
文件 2 (playsound.py):
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)
它在 VS CODE 终端中工作,但在 linux terminal.ERROR:
中不工作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 文件并 link 到这个文件。 文件 1 (start.py):
import os
os.system("python3 /home/shaheer/playsound.py")
文件 2 (playsound.py):
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)