我正在编写一个__init__()
函数,但我有一个错误,即:Expected:)
,进一步还有:Undefined variable: self
真的不明白为什么我会得到这个,你能帮我吗?
我的代码:
class PVT_frame:
"Definition of PVT frame"
def __init__(self, data_rmc['year'], ... ):
###TIME VALUES
self.year = data_rmc['year']
self.month = data_rmc['month']
self.day = data_rmc['day']
...
提前谢谢你。
缩
进你的代码,一切都会好起来的。
class PVT_frame:
"""Definition of PVT frame"""
def __init__(self, data_rmc, *args):
self.year = data_rmc['year']
self.month = data_rmc['month']
self.day = data_rmc['day']
另一件事,对文档字符串使用三重双引号。
- 正确缩进代码。
- 使用
def __init__(self, data_rmc):