如何修复Python中的AttributeError?

2024-05-14 18:17:06 发布

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

我无法成功修复代码中的此错误。Python给我写了以下错误消息:

"Traceback (most recent call last):
  File "C:\Users\Chloé CHAUMETON\Documents\BioAxial\1_R&D\4_Software\2_Python\Measurement_script\Matlab_to_Python\2019\Chloe_script_V3.py", line 114, in <module>
    if 0 < len((lrir)(lrir.name_file)):
AttributeError: 'function' object has no attribute 'name_file' "

我定义了代码的"name_file = 'BSR_Main.exe2018_09_14.csv' "部分,但我不明白python为什么不把这个名字赋给函数。这是我的密码。你知道吗

i_r=[]

def lrir():

lrir = liste_record[i_r]

name_file = 'BSR_Main.exe2018_09_14.csv';

for i_r in range(0,rec-1):

    if 0 < len((lrir)(lrir.name_file)):

        str1 = ligne.find(lrir.name_file,'/')
        pr_rep = os.path.join(dir_PR,s(i_r).name_file)
        log_rep = os.path.join(pr_rep,'Log')
        log_file = glob.glob(os.path.join(log_rep,'*.log'))
        print('log file:',log_file)

Tags: path代码nameinloglenifos

热门问题