Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python EOFError学生_Python - Fatal编程技术网

Python EOFError学生

Python EOFError学生,python,Python,刚刚开始介绍使用Python编写脚本的类。我的第一个实验室让我在读一行时遇到EOFError:EOF的问题。这是我输入的所有内容 first_name = input('Kevin') generic_location = input('Target') whole_number = input('8') plural_noun = input('socks') print(first_name, 'went to', generic_location,

刚刚开始介绍使用Python编写脚本的类。我的第一个实验室让我在读一行时遇到EOFError:EOF的问题。这是我输入的所有内容

    first_name = input('Kevin')
    generic_location = input('Target')
    whole_number = input('8')
    plural_noun = input('socks')
    print(first_name, 'went to', generic_location, 'to buy', whole_number, 'different types of', 
    plural_noun)

不知道如何修复它???

一旦修复了缩进,它运行得很好,但看起来您不应该在这里使用
input()
。(我猜您是在某个脚本运行程序中运行的,它实际上不提供任何关于stdin的输入。)

输出:

凯文去塔吉特买了8种不同类型的袜子

(最后一行不必缩进,但这是一种很好的样式。)

欢迎使用SO!请坐飞机。一旦你修正了缩进,它运行的很好,但是看起来你把数据放在了输入提示应该放的地方。你想要的输出是什么?请澄清。看看你是否需要更多的提示。再想想,你甚至不应该在这里使用
input()
。试试
first\u name='Kevin'
,等等(我猜你是在某个脚本运行程序中运行的,它实际上没有提供任何关于stdin的输入。)相关:太棒了,修复了它!好的,太好了!我发布了一个答案,这在这一点上主要是一种形式
first_name = 'Kevin'
generic_location = 'Target'
whole_number = '8'
plural_noun = 'socks'
print(first_name, 'went to', generic_location, 'to buy', whole_number, 'different types of',
      plural_noun)