Python split string that have two delimited
Question: I want to know how to split a string with more then one delimiter. I have a
problem splitting if one is space?

I trying to read a text file that has this:

> 22.0;2016-01-16 00:16:18

I know how to read a text file to a variable, but when I have problem to split
even a string I can't go further.

All I have now is this code:

    
    
    with open('datasource_3.txt', 'r') as f:
         data = f.readlines()
         for line in data:
             words = line.strip().split(';')
        print words
    


Answer: You can split with the [regular
expression](https://docs.python.org/2/library/re.html) `;|`, like so:

    
    
    import re
    
    x = '22.0;2016-01-16 00:16:18'
    print re.split(';| ', x)
    

This prints `['22.0', '2016-01-16', '00:16:18']`.

