Remove n characters from a start of a string

前端 未结 4 1008
故里飘歌
故里飘歌 2021-02-07 06:50

I want to remove the first characters from a string. Is there a function that works like this?

>>> a = \"BarackObama\"
>>> print myfunction(4,a         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 07:08

    Yes, just use slices:

     >> a = "BarackObama"
     >> a[4:]
     'ckObama'
    

    Documentation is here http://docs.python.org/tutorial/introduction.html#strings

提交回复
热议问题