Python Try-Except inside of Function

后端 未结 6 1918
旧巷少年郎
旧巷少年郎 2020-12-11 23:03

I\'ve got a pretty good understanding of python\'s try-except clause, but I\'m encountering problems when trying to put it inside of a function.

>>>         


        
6条回答
  •  余生分开走
    2020-12-11 23:56

    The NameError is being thrown when the name 'foo' is evaluated, which is before entering the function. Therefore the try/except within the function isn't relevant.

提交回复
热议问题