#capitalize首字母大写,其余小写,返回字符串
------------------------------
s = "i LOVE WangXiaoJing"
print(s.capitalize())
-----------------------------
#title() 将每个单词的首字母变为大写 返回的是字符串
s = "i love wangXIAOJING"
s1 = s.title()
print(s1)
----------------------------------
# upper() 将所有字母变为大写字母 返回的是字符串
s = "I 狗 like dog"
print(s.upper())
------------------------------------
# lower() 将所有字母变为小写字母 返回的是字符串
s = "I 狗 like dog"
print(s.lower())
--------------------------------------
# swapcase() 大小写互换 返回的是字符串
s = "I 狗 like dog"
print(s.swapcase())
-------------------------------------------
# len() 计算字符串长度,不属于字符串的内建函数
# leng统计长度是按照字符个数统计,一个汉字的长度为一
s = "I 狗 like dog"
s1 = "I like dog"
print(len(s))
print(len(s1))
---------------------------------------------
# find() 查找指定字符串,找不到返回-1 第一次找到返回第一次索引值
# index() 查找指定字符串,找不到报错
s = 'asdfghjklasdfghjkl'
s1 = s.find('s', 2)
s2 = s.index('a')
print(s1)
print(s2)
-----------------------------------------------
# count() 计算字符串出现次数 返回整形
s = 'adfsdfasdfasdfsdfsddsss'
print(s.count('s'))
------------------------------------------------
#startswith() 检测是否以指定字母开头 返回布尔值
#endswith() 检测是否 以指定字母结束
s = "I like dog"
print(s.startswith('i'))
print(s.startswith('I'))
print('-'*20)
print(s.endswith('g'))
print(s.endswith('o'))
----------------------------------------------
# isupper() 检测所有字母是否是大写字母 返回的是布尔值
s = "f狗sh"
s1 = "DF狗GH"
print(s.isupper())
print(s1.isupper())
print('='*20)
-----------------------------------------------
# islower 检测所有字母是否是小写字母
s = "f狗sh"
s1 = "DF狗GH"
print(s.islower())
print(s1.islower())
print('='*20)
---------------------------------------------------
#istitle() 检测是否以指定标题显示(每个单词首字母大写)
s = "f狗sh"
s1 = "DF狗GH"
print(s.istitle())
print(s1.istitle())
s2 = "I Like Dog"
print(s2.istitle())
print('='*20)
------------------------------------------------------
# isspace() 检测字符串是否是空字符串
s = ' '
s1 = 'i like '
s2 = ' ' #至少有一个,否则返回False
print(s.isspace())
print(s1.isspace())
print(s2.isspace())
-----------------------------------------------------
#说明:汉字在英文字符包裹中被当作字符处理
s = "I 狗 like dog"
s1 = "I 狗 likedog"
print(s.isalpha())
print(s1.isalpha())
print(s2.isalpha())
--------------------------------------------------------
s = "I 狗 like dog"
s1 = "I 狗 like dog132132"
s2 = "3133"
print(s.isalnum())
print(s1.isalnum())
print(s2.isalnum())
print(s3.isalnum())
# isdecimal()
# isnumeric()
s = '123'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
s = b'101100'
print(s.isdigit())
print('='*20)
s = '123.2'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
print('='*20)
s = '三壹百'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
print('='*20)
s = 'III'
print(s.isdigit())
print(s.isdecimal())
print(s.isnumeric())
s = '日照香炉生紫烟*疑是银河落九天*飞流直下三千尺'
list1 = s.split('*')
print(list1)
s = '日照香炉生紫烟 疑是银河落九天 飞流直下三千尺'
print(s.splitlines())
list1 = ['日照香炉生紫烟', '疑是银河落九天', '飞流直下三千尺']
s = '*'.join(list1)
print(s)
s = 'abc'
print(len(s))
print(s.ljust(5) + 'a')
print(s.center(5, '#'))
print(s.rjust(5, '#'))
# lstrip() 去掉左侧指定字符,默认空格
# rstrip() 去掉右侧指定字符,默认空格
print('---'+s.strip()+'--')
print('---'+s+'--')
print(s.lstrip('a'))
print(s.lstrip('b'))
print(s.rstrip('c'))
# lstrip() 去掉左侧指定字符,默认空格
# rstrip() 去掉右侧指定字符,默认空格
print('---'+s.strip()+'--')
print('---'+s+'--')
print(s.lstrip('a'))
print(s.lstrip('b'))
print(s.rstrip('c'))
#translate() 进行字符串替换
s = '今天晚上我吃的是小炒肉,可好吃了'
table = s.maketrans('小炒肉', '大白菜')
print(table)
print(s.translate(table))
table = s.maketrans('小炒肉', '大白菜和粉条')
print(table)
print(s.translate(table))