“UnboundLocalError: local variable 'input' referenced before assignment”

后端 未结 2 664
小鲜肉
小鲜肉 2020-12-19 14:29

When I run my code I get these errors:

linechoice = input(\"What password do you want to delete?:\\n\")

UnboundLocalError: l

2条回答
  •  萌比男神i
    2020-12-19 15:07

    If you got this error, due to calling input():

    UnboundLocalError: local variable 'input' referenced before assignment

    than you should check whether your runtime python interpreter is 3.x, if you were assuming it is 2.x.

    This Error happened to me while executing on python 3.6:

    if hasattr(__builtins__, 'raw_input'): 
        input = raw_input
    input()
    

    So I got rid of this, and instead used:

    from builtins import input
    

提交回复
热议问题