1. the following built-in functions (built-infunction) can be used for sequence (table, value table, string): s is returned for a sequence len (s: min (s) of the number of elements contained in the sequence return: max (s) of the smallest element in the sequence return: all (s) of the largest element in the sequence return: True, if all elements are True, any (s) returns: Tru... 1. the following built-in functions (built-in function) can be used for sequence (table, value table, string): s is a sequence.
Len (s) returns the number of elements contained in the sequence.
Min (s) return: the smallest element in the sequence
Max (s) return: The largest element in the sequence
All (s) returns True if all elements are True.
Any (s) returns True if any element is True.
2. the following methods are mainly used to query the sequence without changing the sequence itself. they can be used in tables and value tables:
Sum (s) returns the sum of all elements in the sequence.
# X is the element value, and I is the subscript (position of the element in the sequence)
S. count (x) returns the number of times x appears in s.
S. index (x) returns the subscript that x appears for the first time in s.
3. the elements of the value table cannot be changed. the following method applies only to tables:
# L is one table, and l2 is another table
L. extend (l2) adds all elements of table l2 to the end of table l
L. append (x) attaches an x element to the end of l.
L. sort () sorts the elements in l.
L. reverse () reversely sorts the elements in l.
L. pop () returns the last element of table l, and deletes the element from table l.
Del l [I] delete this element
(All of the above operations are performed on the original table, which will affect the original table instead of returning a new table .)
4. The following are some methods used for strings.
# Str is a string and sub is a substring of str. S is a sequence, and its elements are strings. Width is an integer used to indicate the width of the new string.
Str. count (sub) returns the number of times that sub appears in str.
Str. find (sub) return: from the left, find the position where sub first appears in str. -1 is returned if str does not contain sub.
Str. index (sub): returns the position where sub first appears in str from the left. If str does not contain sub, an error is returned.
Str. rfind (sub) returns the position where the sub first appears in str from the right. -1 is returned if str does not contain sub.
Str. rindex (sub) returns the position where the sub first appears in str from the right. If str does not contain sub, an error is returned.
Str. isalnum () returns True if all characters are letters or numbers.
Str. isalpha () returns True if all characters are letters
Str. isdigit () returns True if all characters are numbers.
Str. istitle () returns True if the first letter of all words is uppercase.
Str. isspace () returns True if all characters are spaces.
Str. islower () returns True if all characters are lowercase letters
Str. isupper () returns True if all characters are uppercase letters
Str. split ([sep, [max]) returns: start from the left and use a space as the separator (separator). str is divided into multiple sub-strings for a total of max times. Put the obtained substring in a table and return it. You can use commas or other delimiters in str. split (',').
Str. rsplit ([sep, [max]) returns: start from the right, use a space as the separator (separator), and split str into multiple sub-strings for a total of max times. Put the obtained substring in a table and return it. You can use commas (,) or other delimiters in str. rsplit (',') mode.
Str. join (s): returns the elements in s, which are separated by str and merged into a string.
Str. strip ([sub]): removes spaces at the beginning and end of a string. You can also provide the sub parameter to remove the sub at the beginning and end of the string.
Str. replace (sub, new_sub) returns: replace the sub in str with a new string new_sub.
Str. capitalize (): returns the first str letter in uppercase.
Str. lower () return: Replace all str letters with lowercase letters
Str. upper () return: Replace all str letters with uppercase letters
Str. swapcase (): replace str with uppercase letters, and replace lowercase with uppercase letters.
Str. title () return: uppercase of the first letter of each word in str (separated by spaces)
Str. center (width) returns a string with the length of width. Place the original string in the center of the string. other spaces are spaces.
Str. ljust (width) returns a string with the length of width. the left alignment of the original string is placed into the string, and the other spaces are spaces.
Str. fill UST (width) returns the string with the length of width. place the right alignment of the original string into the string. other spaces are spaces.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service