Thursday, 7 March 2024

python strip string, find index, last index

 https://stackoverflow.com/questions/19454286/python-strip-a-string-from-index

strip string:

>>> mystr = 'foo7bar'
>>> mystr[:mystr.index('7')]
'foo'
>>>

https://stackoverflow.com/questions/9572490/find-index-of-last-occurrence-of-a-substring-in-a-string
last index
string.rindex('bla')
first index
string.index

No comments:

Post a Comment