Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例子
try: x= "" x = input("input x: ") print (x) except EOFError as e: print (x) print ("end")
在 Python 3 中运行此代码会产生以下输出:
结果
两行输出来自EOFError处理程序。看起来 input() 函数正在将提示作为数据读取。请帮忙。
EOFError
您在异常中打印x,您应该打印e
try: x= "" x = input("input x: ") print (x) except EOFError as e: print (e) print ("end")