1. String definitions, single and double quotes, you can use escape \2. Stitching string str1+str23. Convert to String  STR (1000000000000000L), ' 1000000000000000 '  REPR (100000000000000000L), ' 100000000000000000L '  REPR is an operation that retains the original value 4.raw_ Input ("Valus:") generally receives user input using this method 5. Multiple lines of string or long strings can be either "Val" or "" "" Val "" "6. A newline can also use \7. When you have a lot of special characters to escape, you can use R ' He\nllo ', r ' hello\ ' ERROR 8. Use Unicode characters with the U ID, such as: U ' hello ' 9. Sequence index identification order before and after: 0. 1..2... before-and-after: -1...-2...-3...10.python 6 sequences lists, tuples, strings, Unicode strings, The buffer object, Xrange object list can be modified, tuples and strings cannot be modified 11. General operation of sequence index, shard, add, multiply, len,min,max,in, Iteration 12. Sequence of Shard operations All sequences support shard operations Shards can do various operations on sequences: Add, filter, copy, delete, modify, stack, queue, reverse Examples: s[9:30],s[9:],s[9:30:3],s[::4]13. Some basic operations supported by the sequence Add the same type of sequence can be connected, otherwise it throws an exception    [1,2,3]+[4,5,6] multiplication 3 * [' a '] --> &NBS P [' A ', ' a ', ' a '] in determine if there is a ' W ' in ' www ' true &nbs P ' a ' in ' www ' false [All-in-all] in [[1,2,3],[4,5,6],[ 6,7,8]] true sequence length len Len (LST) sequence Max max MAX (LST) sequence minimum min min (LST) 14. list, sequence of one can change content list (' hello ') list function, convert value to list Example: & nbsp Lst1=list ("hao123") converts a string to a list '. Join (list1) Convert list to string &NBSP Queue table Assignment:lst[1]=3 list Delete: Del lst[1] shard Assignment: name=list (' Perl ') name[2:]= List (' ar ') &NBSp Shard assignment You can replace shards with sequences that are not equal to the original shards, and shards can also delete the contents of the list 15. List of methods append:lst.append (5) Appending an element to the end of the list modifies the value of the original list count:lst.count ([up]) the number of statistics elements that appear in the list extend:lst.extend ( [Three-in-one]) appends the value from another sequence at the end of the list, modifies the original list index:lst.index (' a ') to find the position of the element in the first matching index in the list, and cannot find the exception to be thrown insert:lst.insert (0,val) appends an element to the specified index at the list pop:lst.pop () removes the last element from the list and returns remove:lst.remove (' Val ') removes the first matching element from the list, throws an exception if it does not exist, modifies the value of the original list reverse:lst.reverse () reverses the list, Modify the value of the original list sort:lst.sort () sort change the original list Copy a list the most efficient way, y=x[:],16. Tuples & nbsp; When creating tuples, commas are very critical tuple ([]): Functions to create tuples 17. String Formatting 18. String Constants ( Import string) string.digits String containing the number 0-9 string.letters &NBS p; string containing all letters (uppercase or lowercase) string.lowercase string containing all lowercase letters string.printable String containing all printable characters string.punctuation string containing all punctuation string.uppercase String containing all uppercase letters 19. String Method find, finds strings in longer string, returns the leftmost index where the string is located, returns No 1 example: str1= ' Hi World!!! Hi World haoc Good ' str1.find (' Hi ') #从左向右找到则返回索引所在位置 &NB Sp; str1.find (' Hi ', 1) #从左向右第一个索引之后开始寻找, find back the index location str1.find (' Hi ', 1,20) #从左向右在第1和第20索引之间寻找 rfind index rindex count startwith endstwith join, is the inverse method of split, used to connect elements in the sequence & nbsp Examples: seq=[' abc ', ' BCD ', ' CDE ', ' def '] sep= ' * ' sep.join (seq) # ' abc*bcd*cde*def ' dirs= ', ' usr ', ' bin ', ' env ' ' '/'. Join (dirs) & nbsp # '/usr/bin/env ' ' C: ' + ' \ \ '. Join (dirs) # ' c:\\usr\\bin\ \env ' split, dividing a string into sequences, is the inverse method of join. example: ' a+b+c+d '. Split (' + ') #[' A ', ' B ', ' C ' , ' d '] "Hi World it's good". Split () # [' Hi ', ' world ', ' it ', ' good '], i.e. not input Any delimiter, such as spaces in the string as split rsplit splitlines lower, returns the lowercase form of the string example: ' abc '. LOWER () # ' abc ' islower to determine if the string is all lowercase Example: ' abc '. islower () #True ' abc '. islower () #False capitalize &NB sp;swapcase title istitle upper, returns the uppercase form of the string &NBSp Example: ' ABC '. UPPER () # ' ABC ' isupper, judging if the string is all uppercase Example: ' abc '. isupper () #True ' abc ' . Isupper () #False replace, returns the string example: ' Hi World ', after all occurrences of a string have been replaced. Replace (' Hi ', ' hello ') # ' Hello World ' strip, remove the whitespace on both sides of the string, if you remove the other characters then input parameters, if you want to remove the space to be added in the parameters, that is, the parameter contains what to remove what example: ' ABC ' strip () # ' ABC ' ' * * && ABC * * && BCD * && '. Strip (' *& ') &nbs P # ' ABC * * && BCD ' ' * * && ABC * * && BCD * &&! '. Strip (' *& ') # ' abc * * && BCD * &&! ' ' * * && ABC * * && BCD * &&! '. Strip (' *&! ') # ' abc * * && BCD ' lstrip rstrip translate, like replace, are used to replace portions of a string, except that translate is used to process a single character, that is, you can handle multiple substitutions at the same time 20. Dictionaries
Python Basic Tutorial reading notes