python3 AttributeError:“int”对象没有属性“length”

2024-10-01 00:22:15 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我正在尝试修复这个属性错误,并且已经做了一天半了。我是python新手,尝试将结构化英语代码(伪代码)转换为项目的Python3

Output: 

Traceback (most recent call last):
  File "test.py", line 31, in <module>
    passwordVerifier(password)
  File "test.py", line 16, in passwordVerifier
    passwordArray = password.length()
AttributeError: 'int' object has no attribute 'length'
#!/bin/python3
import os
import sys

import numpy

import office2john

def passwordVerifier(password):
    password = str(password)
    verifier = [numpy.uint16(1)] 
    passwordArray = [numpy.uint8(1)]
    verifier = 0x0000

    passwordArray = [0]
    passwordArray = bytes([])                           
    passwordArray = password.length()


    for password in passwordArray: 
        intermediate1 = 0 
        if password in passwordArray:
            intermediate1 = 1 
        else: 
            intermediate2 = verifier * 2 
            intermediate3 = intermediate1 
            verifier = intermediate3
        return verifier

Tags: 代码inpytestimportnumpylinepassword