# 第5章示例:字符串常用方法

# 大小写
print("hello".upper())        # HELLO
print("WORLD".lower())        # world
print("AbC".capitalize())     # Abc

# 去掉首尾空白 strip()
name = "   皮皮   "
print(name.strip())           # 皮皮
print("***皮皮***".strip("*"))  # 皮皮

# 拆分 split 与合并 join
text = "苹果,香蕉,橘子"
print(text.split(","))        # ['苹果', '香蕉', '橘子']

words = ["苹果", "香蕉", "橘子"]
print("-".join(words))        # 苹果-香蕉-橘子

# 替换、统计、查找
print("我爱吃苹果".replace("苹果", "橘子"))   # 我爱吃橘子
print("banana".count("an"))                 # 2
print("hello".find("l"))                    # 2
print("hello".find("z"))                    # -1,找不到
