首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python如何检查缩进错误?

Python如何检查缩进错误?
EN

Stack Overflow用户
提问于 2018-07-08 09:36:33
回答 2查看 205关注 0票数 -2
import itertools
import string

file = open('list.txt', 'w')

def guess_password(real):
    chars = string.ascii_lowercase + string.digits
    attempts = 0
    for password_length in range(1, 9):
        for guess in itertools.product(chars, repeat=password_length):
            attempts += 1
            guess = ''.join(guess)
            if guess == real:
                return 'password is {}. found in {} guesses.'.format(guess, attempts)
            print(guess)
            file.write(guess + attempts # Unexpected indent error... WHY?!

print(guess_password('your password'))
command = input("()")

我对调用错误的位置进行了注释。我正在尝试做一个程序,给我一个可能的密码列表,并将它们放入记事本文件中

完整的错误回溯如下:文件"Pass_Crack_List.py",第16行file.write(猜测+尝试)#意外缩进错误..,为什么?!TabError:缩进中制表符和空格的用法不一致

此外,我还尝试退格键,直到上一行,然后按enter,错误仍然存在

已解决

错误已修复。它给出了错误3行太晚了(实际上是第13行)。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51228193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档