#字符串操作
s ='Let life be beautifuel like summer flowers'
#按照指定的内容切割,返回一个列表
#sep:指定按照什么内容进行切割
#maxsplit:指定切割次数
#ret = s.split(' ', maxsplit = 1)
#print(ret) # ['Let', 'life be beautifuel like summer flowers ']
#ret = s.split( )
#print(ret) #['Let', 'life', 'be', 'beautifuel', 'like', 'summer', 'flowers']
#从右端开始切割
#ret = s.rsplit(' ', maxsplit= 1)
#print(ret) # ['Let life be beautifuel like summer', 'flowers']
#s = 'Hello\n world'
#按照换行进行切割
#print(s.splitlines()) # ['Hello', ' world']
s = 'death like autumn leaves'
ret = s.split( )
print(ret) # ['death', 'like', 'autumn', 'leaves']
#字符串的拼接
s2 = '*'.join(ret)
print(s2) # death*like*autumn*leaves
#查找统计判断
s = 'Goals determine what your going to be'
#字符串查找,找到返回首次出现的位置(下标),找不到返回-1
ret = s.find('are')
print(ret) # -1
#从后面开始查找 ret = s.rfind()
ret = s.rfind('be')
print(ret) # 35
#统计出现的次数
ret = s.count('if')
print(ret) # 0
#判断是否以指定的内容开头
ret = s.startswith('Hi')
#判断是否以指定的内容结束
ret = s.endswith('be')
print(ret) #True
#转换及替换
s = 'Do not pray for easy lives. Pray to be stronger men '
#转化为大写
print(s.upper()) # DO NOT PRAY FOR EASY LIVES. PRAY TO BE STRONGER MEN
#转换为小写
print(s.lower()) # do not pray for easy lives. pray to be stronger men
#大小写转换
print(s.swapcase()) # dO NOT PRAY FOR EASY LIVES. pRAY TO BE STRONGER MEN
#首字母大写
print(s.capitalize()) # Do not pray for easy lives. pray to be stronger men
#每个单词首字母大写
print(s.title()) # Do Not Pray For Easy Lives. Pray To Be Stronger Men
#类型判断
s = 'All rivers run into the sea.'
#是否是全大写
print(s.isupper()) # False
#是否是全小写
print(s.istitle()) # False
s = '123456'
#是否是全数字
print(s.isdecimal()) # True
#是否全是字母
print(s.isalpha()) # False
s = 'ASCDEFG'
#是否全是数字或者字母
print(s.isalnum()) # Ture