print("hello world") name = ' Wang Wei cock silly ' Print (name) Wang Wei age_of_ silly cock = 18 # Type: determining the type of a variable str1 = ' Hello ' Print (type (str1)) # value str2 ='hello' print(type(str2)) ''' Users interact with the program Input: input() Output: print() '' ' # Allow the user to enter a user name name = the INPUT ( ' Please enter the name: ' ) # Output user name Print (name) print(type(name)) # Double quotes str2 = " encounters Mickey Mouse " Print (str2) Print (of the type (str2)) # Triple quotes Str3 = '' ' Anhui Province Hefei Most cattle manner Institute HEFEI ''' print(str3) print(type(str3)) ''' Priority control operation 1 by index value 2 slices 3 length (len) 4 members of the operation in and notin 5 overflow blank 6 segmentation 7 cycles '' ' # 1 by the index value # forward str1 = ' Hello Tank! ' Print (str1 [0]) # H Print (str1 [. 9]) # H # Anti-oriented Print (str1 [-2]) # K # 2 sections (care regardless of tail) str1 = ' ! Tank Hello ' # 0- (5-1) Print (str1 [0:. 5 ]) #步长 print(str1[0:11]) #hello tank! print(str1[0:11:2]) #hlotn! # Length Print (len (str1)) # . 11 # 4 members in operation in and Not Print ( ' H ' in str1) Print ( ' H ' Not in str1) # 5. 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()) # Removal of specified character str2 = ' ! Tank! ' Print (str2.strip ( ' ! ' )) # 6 segmentation Split str1 = ' Hello Tank! ' # Be segmented according to the space within str1 # C sliced out values stored in the [] list. Print (str1.split ( ' ' )) # [ 'Hello', 'Tank!'] # 7 cycle # of str1 string traversal, print each character for Line in str1: Print (Line) ''' Seven formatted output #Placeholder: % S: can replace any type % D: replacement digital type ''' ''' String formatting Alternatively to the # 100% s # Str1 = 'Dear customer, hello! Hello! Your phone bill this month deducted from% s yuan, left 0 yuan '100% ''' ''' String type: Need to know ''' #1.strip,lstrip,rstrip str1 =' hello wuyuefeng ' print(str1) # Remove the clear space Print (str1.strip ()) # remove the spaces left Print (str1.lstrip ()) # remove the right space Print (str1.rstrip ()) # 2 Lower, uppper str1 = ' Hello wuyuefeng ' # converted to lower Print (str1.lower ()) # uppercase Print (str1.upper ()) # . 3 startsWith, endsWith str1 = ' Hello shadiao ' # determined character is equal to the beginning str1 Hello Print (str1.startswith ( ' Hello ' )) # ture # determined character is equal to the end of str1 shadiao Print (str1.endswith ( ' shadiao ' ) ) # ture # 4.format (formatted output) three play # str1 = 'My name IS% S, S% Age My!'% ( 'Tank', 18 is) # ; Print (str1) # Way: according to the position sequence formatter Print ( ' ! My name IS {}, {} My Age ' .format ( ' Tank ' , 18 is )) # Second way: The index format Print ( ' My name IS {O }, Age {My}. 1! ' (the format. ' Tank ' , 18 is )) # three ways: by name format Print ( ' ! My name IS {name}, {My Age Age} ' . the format (Age 18 is =, name = ' Tank ' )) # The Join string concatenation # given, string concatenation only # print ( ''. The Join ( 'Tank', '18 is', 'form GZ')) # The spaces, each of the strings in the list for splicing print ( '' .join ([ ' Tank ' , ' 18 is ' , ' from GZ ' ])) # the _, the list for each string of splicing Print ( ' _ ' .join ([ ' Tank ' , ' 18 is ' , ' from GZ ' ])) # 7. The Replace: string replacement str1 = ' My name IS WangWei, Age 73 is My! ' Print (str1) str2 = str1. replace (' WangWei','sb') print (str2) # . 8, isdigit: determining whether a string is the number Choice = INPUT ( ' select [0,1, 2]: ' ) # determines whether a user input selection of a digital Print (isdigit Choice ().)