Newbie Question... casting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freefall
    New Member
    • Mar 2008
    • 2

    Newbie Question... casting

    What is the preferred way to convert a string to a string_list?
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    Originally posted by freefall
    What is the preferred way to convert a string to a string_list?
    What is a string_list? If you mean splitting the words up into a list of words it would be:
    [code=python]
    >>> txt = 'This is an example string, which will be split'
    >>> txt2 = 'This.String.Wi ll.Be.Split.At. Periods'
    >>> txt.split()
    ['This', 'is', 'an', 'example', 'string,', 'which', 'will', 'be', 'split']
    >>> txt2.split('.')
    ['This', 'String', 'Will', 'Be', 'Split', 'At', 'Periods']
    >>> [/code]

    Comment

    Working...