Thread
:
Need help with python string trim
View Single Post
Mentalist Traceur
2011-04-02 , 18:35
Posts: 2,225 | Thanked: 3,822 times | Joined on Jun 2010 @ Florida
#
6
Originally Posted by
khuong
Thank you very much
Will this be correct?
newstr = str[:strlen]
Yes, that works. Just make sure that when you define str, it gets defined as a string instead of an integer.
For instance, typing "str = 123456789" in python will give you the integer 123456789 (one hundred twenty-three million, four hundred fifty-six thousand, seven hundred eighty nine), instead of the characters "123456789".
By the same token, make sure strlen is defined as an integer. If it gets interpreted as a string, prob'ly won't work.
Also, if this is N900 python development, you can just type "python" in the X-Terminal to get an interactive python shell from which you can test all this stuff.
Quote & Reply
|
The Following User Says Thank You to Mentalist Traceur For This Useful Post:
khuong
Mentalist Traceur
View Public Profile
Send a private message to Mentalist Traceur
Find all posts by Mentalist Traceur