练习:字符串的移位
要求:
>>> a = Nstr(" l love china ") >>> a >> 6 'china l love ' >>> a << 3 'love china l '
代码:
class Nstr(str): def __lshift__(self , other): return self[other:] + self[:other] def __rshift__(self , other): return self[-other:] + self[:-other]