How to remove lines and parts of lines from python strings?
How do you remove parts of strings using python? Such as, if I have something like:
Code:
erme1 sdifskenklsd Another case, how would I have python remove something like: Code:
4:32 aips mana seven Thanks for your time! |
Hello !
You (probably) need to use regular expressions: http://docs.python.org/library/re.html Just to get you started: Code:
>>> re.sub('^erme[0-9]*\s', '', 'erme3 kcielsmkdlfdsiof') Cheers :) |
@OP, you probably should read up the docs for a start.
for you first question and with your sample data, you can just do a split(), then remove the first column Code:
for line in open("file"): Code:
print line[4:] |
Great thanks. I think I will read more documentation.
|
All times are GMT -5. The time now is 01:57 PM. |