''' ''' ''' Basic data types: Digital Type: 1, integer: int The person's age, identity ID number ... 2, floating point type: float People's height and weight, payroll ''' #int age = int(18) print(age) print(type(age)) Age2 =. 19 # automatically recognizes the type Print (Age) Print (type (Age)) #float will = 1:01 print(sal) print(type(sal)) ''' String type: str effect: Name, sex, nationality, address and other descriptive information definition: In single quotes, double quotes, the three quotes a string of characters '' ' # Single quotes str1 = ' Hello ' Print (str1) Print (type (str1)) # Double quotes str2 = " hello " Print (str2) Print (of the type (str2)) # Triple quotes: You can write multiple lines str3 = '' ' Anhui Province Hefei HEFEI ''' print(str3) print(type(str3)) ''' Master priority actions: 1, according to an index value (forward + reverse take take): can only take 2, a slice (care regardless of the end, step) 3, the length len 4, members and not in operation in 5, remove the blank strip 6, slicing split 7, circulation '' ' # By index values (Forward + Reverse take take): only take # forward taken str1 = ' ! Tank Hello ' Print (str1 [0]) # print H Print (str1 [. 9]) # Print k # Reverse takes Print (str1 [-2]) # K # Slice (care regardless of the end, step) str1 = ' Hello Tank! ' Print (str1 [0:. 4]) # printing hell #步长 print(str1[0:11]) #hello tank! print(str1[0:11:2]) #hlotn! # Length len Print (len (str1)) # . 11 # Members in operations in and not Print ( ' H ' in str1) # True Print ( ' H ' not in str1) # False # Remove Blank Strip # spaces removes left and right sides of the string str1 = ' Hello Tank! ' Print (str1) str1 =' hello tank! ' print(str1) print(str1.strip()) # Remove the specified string str2 = ' ! Tank! ' Print (str2.strip ( ' ! ' )) # Segmentation Split str1 = ' Hello Tank! ' # Be segmented according to the space within str1 # segmentation exists out value [] list Print (str1.split ( ' ' )) # [ 'Hello', 'Tank ! '] # Cycle # of str1 string traversal, print each individual character for Line in str1: Print (Line) ''' String type Need to know '' ' # . 1, Strip, the lstrip, The rstrip str1 = ' Hello Yaya ' print (str1) # remove the clear space print (str1.strip ()) # remove the spaces left print (str1.lstrip ()) # remove the right box print (str1.rstrip ()) # 2, Lower, Upper str1 = ' Hello YaYa ' # converted to lower Print (str1.lower ()) # uppercase Print (str1.upper ()) # . 3, startsWith \ endsWith str1 = ' Hello Yaya ' # determines whether the beginning str1 Hello Print (str1.startswith ( ' Hello ' )) # True # determines whether the end of characters equal str1 Yaya Print (str1.endswith ( ' Yaya ' ) ) # True # . 4, the format (output format) of the three kinds of play str1 = ' My name IS% S, S% Age My! ' % ( ' Tank ' , 18 is ) Print (str1) # Way: the sequence is formatted according to the position Print ( ' My name IS {}, {} Age My! ' .Format ( ' Tank ' , 18 is )) # Second way: The index format Print ( ' ! My name IS {0}, Age {My}. 1 ' .format ( ' Tank ' , 18 is )) # Three ways: by name formatting Print ( ' ! My name IS {name}, {My Age Age} ' .format (Age = 18 is, name = ' Tank ' )) #5、split,lspilt str1 = 'hello tank!' print(str1.split(' ')) #print(str1.lsplit(' ')) #???? # . 6, the Join string concatenation Print ( ' ' .join ([ ' Tank ' , 18 is])) # error # to list each string splicing Print ( ' ' .join ([ ' Tank ' , ' 18 is ' ])) # the spaces, each of the string in the list is spliced Print ( ' ' .join ([ ' Tank ' , ' 18 is ' , ' from GZ '])) # The _, the list for each string of splicing Print ( '_'.join(['tank','18','from GZ'])) # . 7, Replace: string replacement str1 = ' My name IS Yaya, Age 18 is My ' Print (str1) str2 = str1.replace('yaya','qy') print(str2) # . 8, isdigit: determining whether a string is the number Choice = INPUT ( ' select [0,1,2]: ' ) # determines whether a user input selecting a digital Print (choice.isdigit ()) # . 9, index: Index output position str1 = ' Hello Yaya ' Print (str1.index ( ' O ' ))