标签:pre 迭代 转义字符 als 查找 表达 strip() form format
print("123\r\n456\r\n789")
print(r"123")
s_gsh1 = "钓%s"
print(s_gsh1 % "鱼")
s_gsh2 = "我的身高%.2f米,我的体重%.2f公斤。"
print(s_gsh2 % (1.76,78.0))
a = "Hello"
b = "World"
d = {"H":"Hello", "W":"World"}
print("{} {}!".format("Hello", "World"))
print("{1} {0}!".format(b, a))
print("{H} {W}!".format(H="Hello", W="World"))
print("{H} {W}!".format(**d)) #------"**d"属于字典的解包
print("我身高{:.2f}米,体重{:.2f}公斤。".format(1.76, 76.0))
print("abcdefghijklmenopqrstuvwxyz".find("wxy",20))
print("abcdefghijklmenopqrstuvwxyz".index("wxy"))
汉字无大小写区别
print("sal dkfj".islower())
print("sdfHHH".islower())
print("SDFKJ".isupper())
print("SDFKJadf".isupper())
print("士大夫立刻就".islower())
print("士大夫立刻就".isupper())
print("奥斯陆扩大".isalpha())
print("sdfgkjh奥斯陆扩大".isalpha())
print("abcdef%¥…………".isalpha())
print("".isalpha())
print("一二三四".isdigit())
print("一二三四".isnumeric())
print("一二三四".isdecimal())
#区分大小写和空格
print("abcdefghijklmenopqrstuvwxyz".startswith("abc"))
print("abcdefghijklmenopqrstuvwxyz".endswith("xyz"))
print("FFFsdkfjkF".strip("F"))
print("FFFsdkfjkF".lstrip("F"))
print("FFFsdkfjkF".rstrip("F"))
print(" sdkfjk ".strip(), end="---\n")
#被拼接元素具有迭代属性
print("-".join("abc"))
print("".join(["ab", "cd", "ef", "gh"]))
print("--".join(["ab", "cd", "ef", "gh"]))
标签:pre 迭代 转义字符 als 查找 表达 strip() form format
原文地址:https://www.cnblogs.com/TK-tank/p/12345298.html