IdentationError:Unident不匹配任何外部标识级别.(Python)



我是编码Python的新手,我正在学习。

现在我制作了一个代码,但请继续遇到以下错误:

'Identationerror:Unentent不匹配任何外部标识水平。'

我希望你们能帮助我。

password = test123

if password == raw_input('What is the password?'):
    print("Acces given")
  else:
    print("Acces forbidden")
password = test123

if password == raw_input('What is the password?'):
    print("Acces given")
else:
    print("Acces forbidden")

其他需要完全低于语句。因此,您需要像我一样不知情。Python是关于凹痕的,一个缩进中的每件事都相同。因此,在您的情况下,其他语句位于if中。规则是,如果没有其他情况。因此,它给出了错误。

应该看起来像这样:

password = 'test123'
if password == raw_input('What is the password? '):
    print('Access given')
else:
    print('Access forbidden')

进一步阅读:PEP8

最新更新