name=" my name is shi\tzhilong"
print(name.capitalize())
print(name.count("i"))
print(name.center(50,"-"))#居中打印
print(name.endswith("ng"))#判断字符串以什么结尾
print(name.expandtabs(tabsize=20))#将换行符转化成空格
print(name[name.find("i"):])
print(name.format(name='sfs',year=23))
name=" my name is {name} and age is {age}"
print(name.format(name='shizhilong',age='18'))# 标准化
print(name.format_map({'name':'shizhilong','age':12}))#字典标准化
print('ab123'.isalnum())#判断字符是否包含阿拉伯数字
print('ab'.isalpha())#是否包含英文
print('1A'.isdecimal())
print('1A'.isdigit())#是不是整数
print('anss'.isidentifier())#是不是合法的变量名
print('2.5'.isnumeric())#是不是数字
print(' '.isspace())
print('My Name Is'.istitle())#是不是标题
print('My Name Is'.join("//"))#间隔粘贴
print('+'.join(['1','2','3']))#把列表转化为字符串
print(name.ljust(50,'*'))#左填充
print(name.rjust(50,'#'))#右填充
print('shizhilong'.islower())
print('shizhilong'.isupper())
print(' sad\n'.lstrip())#左边去掉空格
p=str.maketrans("ai",'12')#密码替换
print(name.translate(p))
print(name.replace('i','I',2))#替换
print('zhilong'.rfind('g'))# 找到指定字符最右边的位置
print('zhilong'.split("i"))#按照指定字符分割成列表
print('dada\nddads'.splitlines())#
print('alRDADs'.swapcase())#大写变小写,小写变大些
print('alRDADs'.title()) #转化为标题
print('alRDADs'.zfill(50))#字符串的所有操作
网友评论