python3 AttributeError: 'int' 对象没有'length'属性

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3 AttributeError: 'int' 对象没有'length'属性相关的知识,希望对你有一定的参考价值。

嗨,我正在尝试修复这个AttributeError,已经有一天半了。我是python新手,想把结构化的英文代码(伪代码)转换为python 3的项目。

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)

检查一个字符串的长度,使用 len

所以对于 int

passwordArray = len(str(password))

以上是关于python3 AttributeError: 'int' 对象没有'length'属性的主要内容,如果未能解决你的问题,请参考以下文章

[Bug]Python3.x AttributeError: libtest.so: undefined symbol: fact

python3 AttributeError: 'NoneType' object has no attribute 'split'

Python 3.6 AttributeError:模块“statsmodels”没有属性“compat”

python3 AttributeError: module 'urllib' has no attribute 'urlencode'

python reload(sys)找不到,name 'reload' is not defined和Python3异常-AttributeError: module 'sys

AttributeError:模块“张量流”没有属性“会话”