类覆盖出错!
class Nstr(str):def __Ishift__(self,other):
return self + self[:other]
def __rshift__(self,other):
return self[-other:] + self[:-other]
'''
-----------------------python3.6-----------------
>>> a.__rshift__(3)
'om!I love FishC.c'
>>> a << 3
Traceback (most recent call last):
File "<pyshell#63>", line 1, in <module>
a << 3
TypeError: unsupported operand type(s) for <<: 'Nstr' and 'int'
错在哪了?
---------------------------------------------------------
'''
lshift 不是 Ishift BngThea 发表于 2018-6-12 14:52
lshift 不是 Ishift
嗯嗯,谢谢{:5_91:}
页:
[1]