参考:https://stackoverflow.com/questions/57258281/typeerror-init-takes-2-positional-arguments-but-4-were-given
MyBook(title,author,price) will pass four arguments: (self, title, author, price)
会多了一个self的参数
本文探讨了在Python中实例化类时遇到TypeError的问题,即__init__方法接收了额外的参数。通过具体案例MyBook(title, author, price),解析了self参数的含义及其在实例化过程中的作用。
参考:https://stackoverflow.com/questions/57258281/typeerror-init-takes-2-positional-arguments-but-4-were-given
MyBook(title,author,price) will pass four arguments: (self, title, author, price)
会多了一个self的参数
您可能感兴趣的与本文相关的镜像
Python3.10
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
7421
5558
953
1万+
2万+
1万+

被折叠的 条评论
为什么被折叠?