简体   繁体   中英

python3 AttributeError: 'int' object has no attribute 'length'

Hi I am trying to fix this AttributeError and been at it for a day and a half now. I am new to python trying to convert structured english code (pseudo code) to python 3 for a project.

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

passwordArray = len(password)

to check length of a string use len

so for int

passwordArray = len(str(password))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM