Monday, July 30, 2012

Python: split string by given separator

use .split() method:


myString = "1-2-3-4-5-6-7-8"
mySplittedStringArray = myString.split('-')
print mySplittedStringArray # ['1', '2', '3', '4', '5', '6', '7', '8']


Resource:
http://www.tutorialspoint.com/python/string_split.htm
http://jolthgs.wordpress.com/2012/02/12/metodos-join-y-split-en-python/

No comments: