无法锻炼为什么在 __init__ 上出现类型错误
can't workout why getting a type error on __init__
希望有人能帮助我...
具有以下特征:
smartsheet_test.py
from pfcms.content import Content
def main():
ss = Content()
ss.smartsheet()
if __name__ == "__main__":
main()
content.py
import smartsheet as ss
class Content:
""" PFCMS SmartSheet utilities """
def __init__(self):
self.token = 'xxxxxxxxxxxxxxxxxxx'
def smartsheet(self):
smartsheet = ss.Smartsheet(self.token)
然而,当我执行代码时,我得到:
python -d smartsheet_test.py
Traceback (most recent call last):
File "smartsheet_test.py", line 8, in <module>
main()
File "smartsheet_test.py", line 5, in main
ss.smartsheet()
File "/xxxxx/pfcms/pfcms/content.py", line 10, in smartsheet
smartsheet = ss.Smartsheet(self.token)
TypeError: __init__() takes exactly 1 argument (2 given)
是 self
以某种方式传递给 ss.Smartsheet(self.token)
,我所能看到的是我正在传递参数 self.token
。在这一点上,我对 Python 的了解还不算太深。非常感谢任何帮助。
谢谢
亚历克斯
您的当前工作目录中有(或曾经有)一个名为 smartsheet.py
的文件。删除或重命名该文件,并删除任何相关的 .pyc
文件。
希望有人能帮助我...
具有以下特征:
smartsheet_test.py
from pfcms.content import Content
def main():
ss = Content()
ss.smartsheet()
if __name__ == "__main__":
main()
content.py
import smartsheet as ss
class Content:
""" PFCMS SmartSheet utilities """
def __init__(self):
self.token = 'xxxxxxxxxxxxxxxxxxx'
def smartsheet(self):
smartsheet = ss.Smartsheet(self.token)
然而,当我执行代码时,我得到:
python -d smartsheet_test.py
Traceback (most recent call last):
File "smartsheet_test.py", line 8, in <module>
main()
File "smartsheet_test.py", line 5, in main
ss.smartsheet()
File "/xxxxx/pfcms/pfcms/content.py", line 10, in smartsheet
smartsheet = ss.Smartsheet(self.token)
TypeError: __init__() takes exactly 1 argument (2 given)
是 self
以某种方式传递给 ss.Smartsheet(self.token)
,我所能看到的是我正在传递参数 self.token
。在这一点上,我对 Python 的了解还不算太深。非常感谢任何帮助。
谢谢 亚历克斯
您的当前工作目录中有(或曾经有)一个名为 smartsheet.py
的文件。删除或重命名该文件,并删除任何相关的 .pyc
文件。