字符串处理
#!/usr/bin/env python
name = "my name\tis {name} and my age is {year}"
print(name.capitalize())
print(name.count("a"))
#print(name.casefold())
print(name.center(50,"-") )
print(name.endswith("an") )
print(name.expandtabs(tabsize = 30))
print(name.find("name"))
print(name.format(name="lian",year=23))
print(name.format_map({'name':'lian','year':12}))
print('abc123'.isalnum())
print('abcdefH'.isalpha())
print('123'.isdecimal())
print('123'.isdigit())
print('abc123'.isidentifier())#是不是一个合法的变量名
print('123'.isnumeric())#纯数字
print('abc123'.isspace())
print('abc123'.istitle())#首字母大写
print('abc123'.isprintable())#tty file,drive file
print('abc123'.isupper())
print('+'.join(['1','2','3','4','5']))
print('abc123'.ljust(50,"*"))
print('abc123'.rjust(50,'*'))
print('Abc123'.lower())
print('abc123'.upper())
print('\n abc 123\n '.lstrip())
print('-----')
print('\n abc 123\n '.rstrip())
print('-----')
print('\n abc 123\n '.strip())
print('-----')
p = str.maketrans("abcdef",'123456')
print('abc123'.translate(p))
print('abc123a'.replace('a','A',1))
print('abc123'.rfind('b') )#找最右边的下标
print('1,2,3,4,5,6'.split(','))
print('1,2,3,\n4,5,6'.splitlines())#按行分割
print('Abc123'.swapcase())#大小写转换
print('abc123'.title())
print('abc123'.zfill(50))
My name is {name} and my age is {year}
5
------my name is {name} and my age is {year}------
False
my name is {name} and my age is {year}
3
my name is lian and my age is 23
my name is lian and my age is 12
True
True
True
True
True
True
False
False
True
False
1+2+3+4+5
abc123********************************************
********************************************abc123
abc123
ABC123
abc 123
-----
abc 123
-----
abc 123
-----
123123
Abc123a
1
['1', '2', '3', '4', '5', '6']
['1,2,3,', '4,5,6']
aBC123
Abc123
00000000000000000000000000000000000000000000abc123