python对象不接受参数什么意思_类型错误:对象。初始化不接受参数

我被Python中的这种继承行为难住了。据我所知,超级类构造函数被正确调用,尽管语法从2.7到3.5有所不同。Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

Anaconda is brought to you by Continuum Analytics.

Please check out: http://continuum.io/thanks and https://anaconda.org

>>>

>>> import pandas as pd

>>> class MyTimestamp(pd.Timestamp):

... def __init__(self, arg, **kwargs):

... super(MyTimestamp, self).__init__(arg, **kwargs)

...

>>> a=MyTimestamp(1312342152423, unit='us')

>>> a

Timestamp('1970-01-16 04:32:22.152423')

使用Python3.5.1解释器,我得到了以下结果,两者都安装了相同版本的Pandas(0.18.0),但我相信这更多的是一个Python继承的东西。Python 3.5.1 |Continuum Analytics, Inc.| (default, Dec 7 2015, 11:16:01)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

>>> import pandas as pd

>>> class MyTimestamp(pd.Timestamp):

... def __init__(self, arg, **kwargs):

... super().__init__(arg, **kwargs)

...

>>> a=MyTimestamp(1312342152423, unit='us')

Traceback (most recent call last):

File "", line 1, in

File "", line 3, in __init__

TypeError: object.__init__() takes no parameters

MyTimestamp的mro指定:(,

,

,

,

,

)

因此object不是解析顺序中的下一个类。这个错误是从哪里来的,也许更重要的是,我做错了什么,我可以改变来解决这个问题?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值