学习python的第十七天【字符串内置】
字符串: #__author:"hanhankeji" #date: 2019/12/7 # string 字符串 a = "hello" print(a) #hello #可以计算 print(a*2) #hellohello # 切片去取内容 print(a[2::]) #llo #in 关键字去判断是不是在容器里面 print("ll" in a) #True 如果内容在里面返回正确值 #格式化 %表示 #字符串的拼接 aa = "123" bb = "456" cc = aa + bb print(cc)#123456 print( "".join([aa,bb]))#123456 用join 拼接 #字符串的内置方法: st = "hello w\torld{name}" print(st .count("l"))# 3 数l的个数 print(st .capitalize())#首字母大写 Hello world print(st .center(50,"*")) #*******************hello world********************居中文本在符号中间 print(st .endswith("ld")) #True 以XX结尾 不对就Falce print(st .startswith("ld")) #False 以什么开头