Python Learning Notes (22) method of sequence

Source: Internet
Author: User
Tags string back

Note:

#the 22nd standard Library-Regular#This introduces the author's supplemental sequence, which is followeds = [1,2,3,4,5,6]len (s)#number of elements of SMin (s)#s the smallest elementMax (s)#s the largest elementAll (s)#returns True if all elements in S are trueAny (s)#returns True if any element in S is true#Query method for the tuple listSUM (s)#returns the and of all elements in SS.count (x)#x is the element, X is the number of occurrences of this element in SS.index (x)#x is the element, X is the index of the element in S, subscript#additions and deletions sort, apply list#Here are some ways#I remember seeing it before with help, especially the list .#the 10th part of the summary with Help when http://www.cnblogs.com/liyihao/p/7655676.htmlS1= [7,8,9]s.extend (S1)#Add all elements of the list to the end of S S1S.append (x)#increase the X element at the end of SS.sort ()#sort S This list, from small to largeS.reserve ()#reverse OrderS.pop ()#The last element is deleted and returneddelS[2]#Delete an element with an index of 2#Delete operations are performed on the original table, directly affecting the original table, resulting in table changes, not returning a new list#The Str class is also a tuple, but Str is some way of changing the string#The essence of these methods is not to manipulate the original string, but to delete the original STR, the new STRs ='ADSFDF'S1='D'S.count (S1)#The number of occurrences of S1 in SS.find (S1)#looking from the left, S1 the first occurrence in S, if S has no S1, returns-1S.index (S1)#from the left to find, S1 in S for the first time the index position, if s inside no s1, errors.find (S2)#s.index (S2)S.rfind (S1)#starting from the right, S1 the position where s first appeared (the index number is returned, the index number is from the left), and if there is no S1 in S, returns-1S.rindex (S1)#starting from the right, S1 the first occurrence of S, if there is no S1 in S, errors.rfind (S2)#s.rindex (S2)S.isalnum ()#s This str is full of letters or numbers return true, not falseS.isalpha ()#s This time all the characters in STR are letters, return true, not falseS.isdigit ()#all characters are numeric true, not falseS.istitle ()#the first letter of all words is uppercase true, not falseS.isspace ()#all characters are spaces True, not falseS.islower ()#all characters are lowercase True, not falseS.isupper ()#all characters are uppercase True, not false#syntax: str.split (str= "", Num=string.count (str)).#Num=string.count (str)) intercepts a string with the Str delimiter, and only the NUM substring if NUM has a specified value#put the split string back in the listL='F D S J a n'L.split (' ', 6)#Pass 2 parameters, one is divided by what, one is the number of splitsL.rsplit (' ', 5) L='F J D S J A J N'L.split ('J', 2)#It is important to note that the number of splits is 2 and 3 pieces are divided .L.rsplit ('J', 2)#split from right, split 2 times with J as delimiter#syntax: str.join (Sequence)L ='3's= ['1','2','3']l.join (s)#combine elements of S, with Str as delimiters, into a single stringL='F D S J a n's= ['1','2','3']l.join (s)#This is inherited above, just start to see half a day do not understandL='F D S J a n'L.strip ()#remove whitespace from beginning of string and resultL='F D S J a n'L.strip ('F')#string that removes the beginning and result of the string, parameter ' F 'L='F D S J a n'L1='F'#dispensableL2 ='W'#dispensableL.replace ('F','W')#Replace the parameter F with parameter W inside lL='F D S J an'l.capitalize ()#The first letter is capitalized and the other caps are lowercaseL.lower ()#All lowercaseL.upper ()#ALL capsL.swapcase ()#uppercase to lowercase, lowercase to uppercaseL.title ()#capitalize the first letter of each word, separated by a space

Python Learning Notes (22) method of sequence

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.