2019.10.23 day 3

# Initials 
S = 'ab &; CDe; Ftg; the Hi' 
# S1 = s.capitalize () 
# all capital letters 
S2 = s.upper () 
Print (S2) 
# all lowercase 
S3 = s.lower () 
Print (S3) 
# reverse case 
S4 = s.swapcase () 
Print (S4) 
# capitalize the first letter of each word 
S5 = s.title () 
Print (S5) 
# centrally and filled 
s6 = s.center (30, ' - ') 
Print (S6) 
# variables have' \ 'filled preceding character 8 
S7 = s.expandtabs () 
Print (S7) 
# check variable number of characters 
S8 = len (S) 
Print (S8) 
# What is determined is the beginning startsWith 
S9 = s.startswith ( 'ab &', 0,5) 
Print (S9) 
# determines in what end endsWith 
S10 = s.endswith ( 'E', 0,5) 
Print (S10) 
# find the index elements by : index find #index if not found error would rather find returns -1 not found
= s.find S11 ( 'F') 
Print (S11) 
# delete the character left and right (default blank) Strip 
S12 = s.strip () 
Print (S12) 
# delete the character left (default blank) lstrip 
# delete the right characters (a space by default ) the rstrip 
# check there are several variables corresponding character conut 
S13 = s.count ( 'the CD') 
Print (S13) 
# split variable listing 
S14 = s.split ( ';') 
Print (S14) 

# # format three methods of output format 
# S15 = 'my name is {}, {year}, {} hobbies, again I'm {}'. format ( 'Stayed', 21, 'female', 'Li Mingjun') 
# Print (S15) 
# S16 = 'my name is {0}, {1} this year, hobbies, {2}, again I call {0}'. format ( 'Stayed', 21, 'female') 
# Print (S16 ) 
# = the INPUT name ( "name:") 
# = the INPUT Age ( "Age:") 
# = the INPUT Hobby ( " Hobbies: ")
# S17 = 'My name is {name} year {age} hobby {hobby}, repeat my name {name}'. Format (name = name, Age = Age, Hobby Hobby =) 
# Print (S17) 
# of #IN common two uses 
# for i in S: 
# Print (i) 
# 
# IF "F" in S: 
# Print ( 'you entered contains illegal characters') 
# = S '132a4b5c' 
# s1 = (s.split ( 'A')) [0] 
# Print (S1) 
# S2 = S1 [0] + S1 [-1: 0: -1] 
# Print (S2) 
S = 'afdser' 
I 0 = 
# for I in S: 
Print # (I) 
# the while S: 
# Print (S [I]) 
# I =. 1 + 
# IF I> len (S): 
# BREAK 

# integer addition calculator 
# contunt = input ( 'enter you want to evaluate and two numbers separated by commas') 
# = contunt contunt.replace ( '', '') 
# Contunt.split s = ( '+') 
# S1 = int (S [0]) + int (S [. 1]) 
# Print (S1) 
# 

S = '12 is' 
Print (s.isalnum ())

 Capitalize the first letter: capitalize

 ALL CAPS: upper

Lowercase: lower

Case reverse: swapcase

Word capitalized: title

Centered and filling: center

Backslash variable t '\ t' filled front 8: expandtabs

Check the variable number of characters: len

What to begin with startswith

To what end endswith

By looking for the index elements: find index # difference is that index will not find an error, find returns -1

Delete both sides of the character (default is a space) startip

Delete the spaces left: lstartip

The right to delete: rstartip

There are several variables to check the corresponding character: count

Split variables: split

Output formatting three methods: format

Replace characters: replace

Traversal variables: for i in s:

Determine whether variables are numbers: isdigit

Determining whether the variable letters: isalpha

Determines whether letters or numbers: isalnum

 

Guess you like

Origin www.cnblogs.com/LMJlmj/p/11729965.html