python - 无法解决为什么在 __init__ 上出现类型错误

标签 python class smartsheet-api

希望有人能帮助我...

具备以下条件:

smartsheet_test.py

from pfcms.content import Content

def main():
    ss = Content()
    ss.smartsheet()

if __name__ == "__main__":
    main()

内容.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 文件。

关于python - 无法解决为什么在 __init__ 上出现类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39375092/

相关文章:

Python - 需要像对象这样的字节,而不是 str

python - 在 time.struct_time 对象中添加一天

c++ - 两个单独的类不共享相同的数据C++

java - 为什么在构建器设计模式中使用嵌套类,为什么不能使用setter在同一个类中构建对象

C++ 函数从对象数组返回对象的拷贝。这是默认行为吗?

PHP 错误 :Unknown SSL protocol error in connection to api. smartsheet.com:443

python - 如何使用python获取文件夹中的工作表ID数组

python - 在不同的程序中使用相同的 excepts

python 3 : Standard way to surpress the b' prefix when printing

smartsheet-api - Smartsheet - 使用 API 将工作表下载为 Excel 文件