If you have a "multiline" variable like
- Code: Select all
a = "hello\nworld\nlinux\nrocks"
Then you can use Python's
find method and substring (
[start:count]) context to extract a particular portion:
- Code: Select all
print s[0:s.find("\n")]
That will print
- Code: Select all
hello
You could also find out how many of your delimiters (string separators) there are in your "mulitline" variable.
- Code: Select all
s.count("\n")
Then ultimately you could also transform your "multiline" variable into an array using Python's
split function
- Code: Select all
arr = s.split("\n")
Then you could use a loop to go through those.
Here is a site with some good references on it for Python. You can see the definitions for each of those methods, like the
find method,
int find(sub [,start[,end]]), for example.
I hope that helps a little bit.