# 字符串
# 有序的字符集合
# 可切片
# 不可变,修改就是重新赋值
# a="hello "
a="hello"+"\n"
print(a)
print(r"hello"+"\n")
a="hello caona"
print(a.capitalize()) #第一个单词首字母大写
print(a.title()) # 每个都首字母大写
print(a.count("o"))
print(a.index("c"))
print(a.isupper())
print(a.islower())
print(a.isdigit())
print(a.upper())
print(a.endswith("a"))
print(a.startswith("h"))
print(a.replace("l","*"))
print(a.casefold())
print(a.center(20,"*"))
print(a.find("e"))
print(a.index("e"))
a1="{} is sb ,age is {}"
print(a1.format("caona",12))
a1="{name} is sb ,age is {age}"
print(a1.format(name="caona",age=18))
print(" ".isspace())
b=["1","2","3"]
print("_".join(b))
print(a.ljust(20,"*"))
print(a.rjust(20,"*"))
c=" df \n \t "
print(c)
print(c.strip())
print(c.rstrip())
print(c.lstrip())
d="my socre is 100,i want 110"
print(d.replace("100","1000"))
d="my socre is 100,i want 100"
print(d.replace("100","88",2))
print(a.split(" "))
print(a.rsplit())
print(a.swapcase())#大变小,小变大
print(a.zfill(30))# 长度30,不够0来凑
转载于:https://www.cnblogs.com/xh716/p/11551615.html