关于'finally'字的Jython语法错误

Rom*_*man 4 python exception-handling jython grinder

这是一个导致错误的片段:

net.grinder.scriptengine.jython.JythonScriptExecutionException: SyntaxError: ('invalid syntax', ('C:\\grinder-3.7.1\\lib
\\.\\nb-romg-file-store\\current\\grinder_test.py', 131, 9, '        finally:'))
Run Code Online (Sandbox Code Playgroud)


    ss = ''
    self._suggestionLock.acquire()
    try:
        ss = suggestion_strings.next()
    except StopIteration:
        suggestion_strings = suggestions_generator()
        ss = suggestion_strings.next()
    finally:
        self._suggestionLock.release()
Run Code Online (Sandbox Code Playgroud)

这可能有什么问题?

jd.*_*jd. 5

你在使用Jython 2.4吗?try/except/finally在Python 2.5中引入.

  • 您可以在try/finally块中嵌套try/except块. (2认同)