【发布时间】:2021-09-25 14:21:14
【问题描述】:
我是 python 新手,遇到了这个我无法理解的问题
AttributeError: 'str' object has no attribute 'path'
class extractor:
"""This class will find the path for the pdx"""
def __init__(self, pdx_name,path):
self.pdx_name = pdx_name
self.path = path
def __str__(self):
return self.pdx_name
def find_folder(self):
if os.path.exists(self.path):
return self.path
也许有人可以解释发生了什么,我认为这很简单,我仍然没有理解。
谢谢!f
【问题讨论】:
-
这些形式的函数属于一个类——不是独立的。那是你的错误。
-
你是如何使用你的提取器类的?我认为您至少需要添加一个代码 sn-p 来显示其用途。你的错误是什么时候发生的?
标签: python python-3.x function class methods