python - 为什么我在尝试使用 _init_ 时会出错?
问题描述
所以我只是想在我的 Python 3.7.0 IDLE (Shell) 中从 python.org 做同样的基本类示例,当我尝试运行这段代码时:
class Giraffes:
def _init_(self, spots):
self.giraffe_spots = spots
gerald = Giraffes(100)
它给了我这个错误:
Traceback (most recent call last):
File "<pyshell#69>", line 1, in <module>
gerald = Giraffes(100)
TypeError: Giraffes() takes no arguments
类中的 init 函数不会Giraffes
让 Gerald 接受参数self
吗?
解决方案
推荐阅读
- angular - 在 JHipster 中创建实体后重定向到路由
- angular - 更新输入数组
- android - 使用可访问性滚动搜索栏
- c# - 使用 MVC C# 应用程序使用 Gsuite 登录
- php - 如何通过表格构建器中的按钮将信息传递给表单构建器?
- asp.net - 使用 gridview aspx 更新 SQL Server 表
- php - 为外部送货服务购买订单时哪个 Woocommerce 挂钩
- spring-boot - spring boot中redis和solr的metrics
- excel - Excel - VBA - 在单元格中检测图像的功能
- dart - Dart:当你导入一个文件时,你会导入文件导入的所有内容吗?