Why am I getting a SyntaxError in the Python interpreter?

前端 未结 3 810
天命终不由人
天命终不由人 2020-12-21 16:57

This code works when I try it from a .py file, but fails in the command line interpreter and Idle.

>>> try:
...     fsock = open(\"/bla\")
... excep         


        
3条回答
  •  失恋的感觉
    2020-12-21 17:30

    You need to leave a blank line to close the except block. The ... indicates it is still trying to put code in that block, even though you dedent it. This is just a quirk of the interactive interpreter.

提交回复
热议问题