简体   繁体   中英

TypeError: str object is not callable

This is my code:

fi=tarfile.open(os.path.join(pathin,file_in),'r')
list-fi.getmembers()
entries_list[]
for lis in list:
    name_list=lis.name()
    entries_list.append(name_list)
print entries_list.

At the line name_list=lis.name() , I'm getting the error str object is not callable . Could you explain why?

Thanks in advance.

lis.name is a string, so lis.name() tries to call this string. Because strings aren't callable, you get the error str object is not callable .

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