var = "hello world"
#Add a new string after the 'var'.
var.__add__('Hi')
#From the string 'var',query the number of character 'o' in the specified area.
var.count('o',0,len(var))
#Get a string of length 50,where 'var' is centered and the rest is supplemented by '*'.
var.center(50,'*')
#Convert the first character of a string to upper.
var.capitalize()
#Convert upper to lower.
var.casefold()
#Determine 'var' has contain 'o'.
var.__contains__('o')
#Turn the tabs to space in the string.
var.expandtabs()
#Determine whether a string ends with a specified char.
var.endswith('d',0,len(var))
#Encoding strings in coded formart.
var.encode()
#Determine 'var' equals 'var2'.
var2 = 'hello woreld'
var.__eq__(var2)
#格式占位符,输出结果Hi,Lili.
print('{0},{name}'.format('Hi',name = 'Lili'))
#Determine whether a char is in a string.
var.find('o',0,len(var))
#Determine 'r' is greater than 'd'.
print('r'.__gt__('d'))
#Determine 'r' is greater than or equal to 'd'.
print('r'.__ge__('d'))
#Quety the index of char from a string.
var.index('o')
#Determine whether 'var' is an identifier.
var.isidentifier()
#Determine whether 'var' is a number.
var.isdigit()
#Determine whether 'var' is alphabet.
var.isalpha()
#Determine whether 'var' is an alphabet or a number.
var.isalnum()
#Determine whether 'var' is a decimal number.
var.isdecimal()
#Detemine whether 'var' is all lower letters.
var.islower()
#Determine whether 'var' is a number.
var.isnumeric()
#Determine whether 'var' is a printable char.
var.isprintable()
#Determine whether 'var' is a space.
var.isspace()
#用'var'把列表中元素连接产生一个新的字符串
print(var.join(['A','B','C']))
#获得一个指定长度的字符串,'var'在最左边,其余的使用'-'补充
var.ljust(10,'-')
#Convert upper to lower.
var.lower()
#Remove 'var' left space.
var.lstrip()
#Get 'var' length.
var.__len__()
#Determine 'var' is less than or equal to 'd'.
var.__le__('d')
#Determine 'var' is less than 'd'.
var.__lt__('d')
#set 'var' mapping relations.
var.maketrans('')
#以第一个'l'的位置把var分隔成3块。
var.partition('l')
#Replace 'o' to 'p' in 'var'.
var.replace('o','p')
#Lookup the specified string from the right.
var.rfind('')
#Lookup the specified string from the right and report the exception if it is not found.
#var.rindex()
#Get a string of the specified length,where 'var' is aligned to the tight,
# and the insufficient characters are filled with '-'.
var.rjust(10,'*')
#从右边开始数,以第一个'l'的位置把var分隔成3块。
var.rpartition('l')
#Use specified char conduct section for 'var',section 10 slice.
var.rsplit('s',10)
#Delete the specified char at the end of a string,Default is space.
var.rstrip('')
#Use specified char conduct section for 'var'.
var.split()
#Use the newline char to separate strings and return a list.
var.splitlines()
#Determine whether 'var' begins with 'h',from 0 to len(var).
var.startswith('h',0,var.__len__())
#Delete the spacified char before and after 'var'.
var.strip('')
#Upper to lower and lower to upper.
var.swapcase()
#Turn to title.
var.title()
#同maketrans方法创建的映射表一起使用,进行字符替换
var.translate()
#Lower to upper
var.upper()
#Specifies the length of a string,'var' is right, and the front is filled 0.
var.zfill()