Python - Removing first x characters
Is there any easy way to remove the first x characters of a string? I'm looking for the equivalent of substr if possible.
|
To process a string in Python, you use indexes
eg Code:
s = "astring" to get better understanding... |
While I'm not sure exactly what you're doing, I feel compelled to mention awk. If you're parsing a text file then awk may well be more suitable. There's a TON of functionality in awk that isn't really documented all that well in the awk man page. A good primer is here:
http://sparky.rice.edu/~hartigan/awk.html HTH Jon |
>>> s = '0123456789'
>>> s[1:] '123456789' >>> s = s[1:] >>> s '123456789' |
All times are GMT -5. The time now is 05:18 PM. |