# -*- coding: utf-8 -*-标签:字符,name,python,菜鸟,str1,字符串,print,age From: https://www.cnblogs.com/liyuzhoupan/p/16588350.html
str1 = "my name is liyuzhoupan"
# 首字母大写
print(str1.capitalize())
# 统计字符串中的字符出现的次数
print(str1.count("n"))
# 自动补齐多少位,不够的用字符#替代
print(str1.center(50, "-"))
# 判断是否已字符“pan”为结尾
print(str1.endswith("pan"))
# 输出tab建
print(str1.expandtabs(tabsize=20))
# 格式化
print("my name is {name} ,age {age}".format(name="liyuzhoupan", age=23))
# 判断是否为阿拉伯字符或者数字
print("123adsf".isalnum())
# 判断是否为整数
print("123".isdigit())
# 判断是否大写
print("NAME".isupper())
# 字符转大写
print("name".upper())
# 字符转小写
print("NAME".lower())
# 替换字符串的中值
p = str.maketrans("abcdefj", "原来你是个人才")
print("my name is coffe".translate(p))
# 替换字符串中的值
print(str1.replace("m", "A", 1))
# 字符切割
print(str1.split(" "))
print(str1.split(" "))