Name="My\ tName is {name} and I am {year} old "
Print (Name.capitalize ())#首字母大写
Print (Name.count ("A"))#总共多少个a
Print (Name.center (40M"-"))#总长度是50, the name string is in the middle of the----
Print (Name.encode ())#转换成字符串
Print (Name.endswith ("Ex"))#是否以ex结尾, yes. Returns True
Print (Name.expandtabs (Tabsize=30))How many spaces does the #\t key have?
Print (Name.find ("Y"))#从哪个索引开始的
Print (Name[name.find ("Name"):9])#字符串也可以进行切片处理
Print (Name.format (Name=' Alex ',Year=23))#给name和Year赋值, like the map effect in the following sentence
Print (Name.format_map ({' Name ':' Alex ',' Year ':12}))#
Print (Name.isalnum ())#是不是包含阿拉伯的数字False
Print' ab123 '. Isalnum ())#是不是包含阿拉伯的数字True, only numbers and letters.
Print' AbN '. Isalpha ())#是不是字母
Print' 1 a '. Isdecimal ())#是不是十进制
Print' 1 a '. IsDigit ())#是不是整数
Print' A1A '. Isidentifier ())#判断是不是一个合法的标识符 (variable name)
Print' A1A '. Islower ())#判断是不是小写
Print' A1A '. Isupper ())#判断是不是大写
Print' A1A '. IsNumeric ())#判断是不是只有数字在里边
Print' A1A '. Isspace ())#判断是不是空格
Print' MY Name is '. Istitle ())#判断是不是每个首字母大写
Print' MY Name is '. isprintable ())#判断是不是可以打印, TTY file,drive file is not generally printable
Print‘‘
' + '. Join ([' 1 ',' 2 ',' 3 ']))#输出1 +2+3, output by format
Print (Name.ljust (40M‘*‘))#保证长度是50, right not enough to fill *
Print (Name.rjust (40M‘*‘))#保证长度是50, left not enough to fill *
Print' Alex '. Lower ())#变小写
Print' Alex '. Upper ())#变大写
Print' Alex\ n'. Lstrip ())#
Print‘\ nAlex '. Lstrip ())#strip去空格后回车, Lstrip left to enter the space after
Print' Alex\ n'. Lstrip ())#strip去空格后回车, Lstrip to the right to enter the space after
Print' Alex\ n'. Strip ())#左右都去空格
Print‘------‘)#
p=Str.maketrans ("ABCdef",' 123456 ')
Print"Alex Li". Translate (p))#返回值是1l5x Li, encryption can be processed
Print' Alex Li '. replace (' L ',' L '))#把所以的l替换成L,
Print' Alex Li '. replace (' L ',' L ',1))#只把一个l替换成L
Print' Alex Li '. RFind (' L '))#找到最后边那个值的下标, the return is now 5.
Print' Alex Li '. split ())#按空格把字母分成列表, [' Alex ', ' Li ']
Print' Al ex Lil '. Split (' L '))#按字母l把字母分成列表, [' A ', ' ex ', ' I ', '], the result of L No, was treated as a delimiter
Print (' 1+2\+3+4 '. Splitlines ())#按换行符进行分隔字符串 [' 1+2 ', ' +3+4 ']
Print (' Alex Li '. Swapcase ())#aLEX Li uppercase edge lowercase, lowercase to uppercase
Print (' Lex Li '. Title ())#Lex Li Initial capital letter
Print (' Lex li ' zfill)#总长是50, not enough front 0
Python day two-string manipulation