Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';内置函数或方法';对象没有属性';更换';_Python_String_Attributeerror - Fatal编程技术网

Python 属性错误:';内置函数或方法';对象没有属性';更换';

Python 属性错误:';内置函数或方法';对象没有属性';更换';,python,string,attributeerror,Python,String,Attributeerror,当我试着在程序中使用它时,它说有一个属性错误 'builtin_function_or_method' object has no attribute 'replace' 但我不明白为什么 def verify_anagrams(first, second): first=first.lower second=second.lower first=first.replace(' ','') second=second.replace(' ','') a=

当我试着在程序中使用它时,它说有一个属性错误

'builtin_function_or_method' object has no attribute 'replace'
但我不明白为什么

def verify_anagrams(first, second):
    first=first.lower
    second=second.lower
    first=first.replace(' ','')
    second=second.replace(' ','')
    a='abcdefghijklmnopqrstuvwxyz'
    b=len(first)
    e=0
    for i in a:
        c=first.count(i)
        d=second.count(i)
        if c==d:
            e+=1
    return b==e
您需要调用
str.lower
方法,方法是将
()
放在它后面:

first=first.lower()
second=second.lower()
否则,
第一个
第二个
将分配给函数对象本身:

>>> first = "ABCDE"
>>> first = first.lower
>>> first
<built-in method lower of str object at 0x01C765A0>
>>>
>>> first = "ABCDE"
>>> first = first.lower()
>>> first
'abcde'
>>>
>>first=“ABCDE”
>>>first=first.lower
>>>首先
>>>
>>>first=“ABCDE”
>>>first=first.lower()
>>>首先
“abcde”
>>>

非常感谢您,我看的地方不对!