Q:

Python splitting of text

I have a text file (.txt) with different lines of words
For example: 
1,2,3,4,5
11,12,13,14,15

How can I use the file.read().split() command to just get the 2nd column...so 2 and 12 for example of the text?

A:

Assuming no spaces around ,:
with open('file.txt') as f:
    for line in f:
        print(line.split(',')[1])

If there could be whitespaces, use re.split():
with open('file.txt') as f:
    for line in f:
        print(re.split(r'\s?,\s?', line)[1])

