Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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 SyntaxError:解析时出现意外的EOF。(打开('myfile.txt',mode='a')作为p:)_Python_Python 3.7 - Fatal编程技术网

Python SyntaxError:解析时出现意外的EOF。(打开('myfile.txt',mode='a')作为p:)

Python SyntaxError:解析时出现意外的EOF。(打开('myfile.txt',mode='a')作为p:),python,python-3.7,Python,Python 3.7,我得到SyntaxError:在解析时出现意外的EOF,即使我的语法是正确的。我怎样才能纠正它 %%writefile mynewfile.txt L stands for Lamborghini M stands for Maserati A stands for Audi 尝试: Python不允许在while/for/if语句中使用空块。您不认为需要在以下情况下完成此open语句:您的语法不正确。with语句需要一个块。你的第二个没有。即使我的语法正确?如果口译员告诉你不是,你认为谁更有

我得到SyntaxError:在解析时出现意外的EOF,即使我的语法是正确的。我怎样才能纠正它

%%writefile mynewfile.txt
L stands for Lamborghini
M stands for Maserati
A stands for Audi
尝试:


Python不允许在while/for/if语句中使用空块。

您不认为需要在以下情况下完成此open语句:您的语法不正确。with语句需要一个块。你的第二个没有。即使我的语法正确?如果口译员告诉你不是,你认为谁更有可能是对的也就是说,尽管我的语法是正确的,但我认为这是一种更谦虚的方式,而不是断言责任在于系统而不是你自己。我只是认为这是正确的。你认为你是为卫星编写代码的超级程序员?不,不,基多:谢谢你,拉多斯拉夫·西布斯基
with open('myfile.txt', mode = 'r') as newfile:
     print(newfile.read())

with open('myfile.txt',mode='a') as p:
File "<ipython-input-24-c4ad87f5e304>", line 1
    with open('myfile.txt',mode='a') as p:
                                          ^
SyntaxError: unexpected EOF while parsing
with open('myfile.txt', mode = 'r') as newfile:
     print(newfile.read())

with open('myfile.txt',mode='a') as p:
     pass