Python Learning Record and python record
Terminal auto-completion. Note that you need to install the readline module> import OS> import rlcompleter, readline> readline, parse_and_bind ('tab: complete') to determine the data type (): Determine the Data Type isinstance (): Common operators used to determine the Data Type: +-*/% ** // <= and or not in Note: String concatenation, + The two sides must be of the same type if ...... else determines small = x if x <y: pass else: y while loop while condition: Loop Current for loop for target expression: loop current list = ['hello ', 'python'] 1. Add an element list to the list. append ('string')-> Add a single string list. extend (['string1', 'string2'])-> insert multiple inserted strings. The parameter is a list. insert (0, 'string3')-> specify the insert position 2. Delete the list element list. remove ('string')-> Delete the specified string del list [1]-> Delete the specified string list. pop ()-> Delete the last one by default. 3. view the list element list []-> View the index () content, note that the list [1:]-> View the content list [:] of the string whose index is 3-> View All content in the list 4. Two-Dimensional list: list5 = ['adb', ['M', 'D'], 'Hello'] list5 [1] [1] = 'D' 5. list of statistical elements. count ('string')-> count the number list. index ('string',)-> Start position statistics position where the first occurrence of 6, reverse element flip sorting menber. reverse () 7. sort (func, key, reverse = Flase) list. sort ()-> list from small to large. sort (reverse = True)-> from large to small 8. Copying elements list1 = list [:]-> is equivalent to copying data, list1 does not change list2 = list-> copy list is equivalent to renaming, list2 changes according to list