lines()
含义:Return the number of lines in a string OR Return the length of a list,because the items in a list are delimited by new lines.
Format
lines(text)
Parameter
Parameter | Definition |
text | text to be counted for number of lines (that is, new-line characters) The text can be the name of a text file, a text string enclosed in double quotation marks, or one or more PSL commands that produce text as output. |
Description
The lines() function returns the number of new-line characters in text. You can also use the lines() function for returning the length of a list, because the items in a list are delimited by new lines.
Example
Code1:
string="Jack and Jill\nwent up the hill";
print("Lines in string:",lines(string),"\n");
Output1:
Code2:
list=[5,"we","are","all","together"];
print("Lines in list:",lines(list),"\n");
Output2: