python learning diary day5

..

name = "my \tname is {name} and i am {year} old"
print(name.capitalize()) #Capitalize the first letter
print(name.count("a")) #Count the number of a
print(name.center(50,"-")) #Center display, complete with characters
print(name.endswith("ex")) # Determine the end character
print(name.expandtabs(tabsize=30)) #Set the size of the tab
print(name[name.find("name"):]) #find the serial number of the character
print(name.format(name='jian',year=22)) #Format character
print(name.format_map( {'name':'jian','year':222} )) #Format character
print('ab23'.isalnum()) # Judge Arabic characters, 0~9 a~Z
print('abA'.isalpha()) #Determine pure English characters a~Z
print('1A'.isdecimal()) #Determine decimal numbers
print('1A'.isdigit()) #Judging numbers
print('a 1A'.isidentifier()) #Determine whether it is a legal identifier
print('a 1A'.islower()) #Determine lowercase characters
print('33A'.isnumeric()) #Determine pure numeric characters
print('33A'.isspace()) #Judging spaces
print('My Name Is '.istitle()) # Determine the capitalization of each first letter
print('My Name Is '.isprintable()) #tty file , drive file cannot be printed and returns False
print('My Name Is '.isupper()) #The judgment is all uppercase
print('+'.join( ['1','2','3']) ) #output 1+2+3
print( name.ljust(50,'*') ) #Display on the left, complete with characters
print( name.rjust(50,'-') ) #Display on the right, complete with characters
print( 'Jian'.lower() ) #Uppercase to lowercase
print( 'Jian'.upper() ) # lowercase to uppercase
print( '\nJian'.lstrip() ) #Go to the left space and enter
print( 'Jian\n'.rstrip() ) #Go to the space on the right and enter
print( 'Jian\n'.strip() ) #Go to the spaces on both sides and press Enter
print('dssdfali'.replace('l','L',1))#replace
print('afshdfhlil'.rfind('l')) #Find the serial number of the rightmost character
print('1+2+3+4'.split('+')) #Split string with character as separator
print('1+2\n+3+4'.splitlines()) #Use \n as the separator
print('JianWei'.swapcase()) #Case swap
print('jian wei'.title()) # becomes the title, the first letter is capitalized
print('jian wei'.zfill(12)) #to the right, not enough to fill with 0

print( '------------------')

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324816663&siteId=291194637