python基础:字符窜操作
name = "my \tname is {name} and i am {year} old"
print(name.capitalize())#首字母大写
print(name.count("a"))#统计有a字母的数量
print(name.center(50,"-"))#打印50个字符,不够的用-代替,内容放中间
print(name.encode())#把字符转二进制
print(name.endswith("an"))#以an结尾
print(name.expandtabs(tabsize=30))#在name之前的tab键留有30个空格
print(name.find("name"))#从左边找
print(name[name.find("name"):])#切片
print(name.format(name='shanshan',year=23))
print(name.format_map({'name':'shanshan','year':23}))
print('name'.isalnum())#阿拉伯数字+阿拉伯字符
print('abA'.isalpha())#输入英文字母
print('1A'.isdecimal())#输入10,6,8进制,不能输入16进制
print('1'.isdigit())#只能输入整数
print('a'.isidentifier())#判断是不是一个合法的标识符(字母开头的变量名)
print(''.isnumeric())
print(''.isspace())#是不是空格
print('My name is '.istitle())
print('My name is '.isprintable())#tty file,drive file
print('My name is '.isupper())#大写
print('+'.join(['1','2','3','4']))
print(name.ljust(50,''))#在后面加上
print(name.rjust(50,'-'))#在前面填补—
print('name'.lower())#把小写变大写
print('name'.upper())#把大写变小写
print('\nshanshan'.lstrip())#去左边空格
print('shanshan\n'.lstrip())#去右边空格
print(' shanshan\n'.strip())#去左右边空格
p = str.maketrans("abcdef",'123456')
print("shanshan".translate(p))
print('shanshan'.replace('s','S',1))#把 s 替换成大写的S,只想换成一个
print('shan shan'.rfind('h'))#找到最右边的小标
print('1+2+3+4+5'.split('+'))#把+取走,提取列表
print('1+2\n+3+4+5'.splitlines('+'))#按换行符划分
print('shanshan'.swapcase())
print('shanshan'.title())
print('shanshan'.zfill(50))