复习:
字符串
#字符串生成
#字符串对齐
#大小写变换
#字符串劈分
#字符串判断相关方法
#字符串替换与合并
#字符串比较
#字符串切片
#格式化字符串
#字符串编码解码
#字符串查询
s1='abc'
s2="a"+'b'+'c'
s3=''.join({'a','b','c'})
s4=''.join(('a','b','c'))
print(s1,s2,s3,s4)
print(s1.ljust(30,'-'))
print(s1.rjust(30,'-'))
print(s1.zfill(30))
print(s1.center(30,'-'))
print(s1.upper())
print(s1.swapcase())
print(s1.lower())
print(s1.title())
print(s1.capitalize())
S='Even though that it was not you.But I know that it is Wonderful.'
print(S.split())
print(S.rsplit())
print(S.split(sep='.',maxsplit=2))
print(S.rsplit(sep='.',maxsplit=2))
print(s1.isalnum())
print(s1.isnumeric())
print(s1.isalpha())
print(s1.isidentifier())
print(s1.isdecimal())
print(s1.replace('a','A'))
print('|'.join(('a','b','c')))
print(s1<s2)
print(s1>s2)
print(s1==s2)
print(S[1:20:2])
name='柠柠'
age=1
print('我是%s,%d岁' % (name,age))
print('我是{},{}岁'.format(name,age))
print(f'我是{name},{age}岁')
n1=name.encode(encoding='UTF-8')
n2=name.encode(encoding='GBK')
print(n1.decode(encoding='UTF-8'))
print(n2.decode(encoding='GBK'))
print(s1.index('a'))
print(s1.rindex('a'))
print(s1.find('a'))
print(s1.rfind('a'))
元组&集合&列表&字典