1 # expandtabs,断句17
2 # s = "username\temail\tpassword\nluofei\tluofei@qq.com\terwer\nluofei\tluofei@qq.com\tyrth\n"
3 # m = s.expandtabs(17)
4 # print(m)
5
6
7 # isalpha判断是否字母
8 # test = "ssdsg"
9 # v = test.isalpha()
10 # print(v)
11
12
13 # # # 判断是否数字 只判断首字母?
14 # test = "6767rr6"
15 # v = test.isalnum()
16 # print(v)
17
18
19 # # 字母,数字,下划线:标识符 判断字符串是否是有效的 Python 标识符,可用来判断变量名是否合法
20 # test = "6767rr6"
21 # v = test.isidentifier()
22 # print(v)
23
24 # isnumeric可以判断中文的数字
25 # test = "三"
26 # v = test.isnumeric()
27 # v2 = test.isdigit()
28 # print(v,v2)
29
30 # 是否存在不可显示的字符:isprintable \t是制表符,\n是换行
31 # test = "sdofad\tfofasdn"
32 # v = test.isprintable()
33 # print(v)
34
35 # 判断是否全部是空格
36 # test = " "
37 # v = test.isspace()
38 # print(v)
39
40 # itle 转化首字母大写,isitle,判断是否为都首字母大写的标题
41 # test = "Rnsdl sdoan adfoam adldfd is"
42 # v = test.title()
43 # print(v)
44
45 # ******************************
46 # join,将字符串中的每一个元素,按照指定分隔符拼接。内部逻辑是循环加入
47 # test = "你是风儿我是沙"
48 # t = " "
49 # v = t.join(test)
50 # print(v,t)
51 # s = "插一脚".join(test)
52 # print(s)
53
54 # ljust,rjust填充字符
55 # test = "alex"
56 # v = test.ljust(20,"*")
57 # s = test.rjust(30,"_")
58 # print(v,s)
59 #
60
61 # 判断小写和变成小写 扩展:判断和变成大写
62 # test = "Ales"
63 # v1 = test.islower()
64 # v2 = test.lower()
65 # v3 = test.isupper()
66 # v4 = test.upper()
67 # print(v1,v2,v3,v4)
68
69
70 # 去除左右空白 \t \n,还可以在参数中指定字符去掉
71 # test = " alex "
72 # v1 = test.lstrip()
73 # v2 = test.rstrip()
74 # v3 = test.strip()
75 # print(v1,v2,v3)
76 # 参数示例 test.strip("ex") 找参数中的匹配项
77
78 # 按照对应关系转化
79 # test = "你dfhah39y23ehh"
80 # m = str.maketrans("12345","aeiou")
81 # testtrans = test.maketrans(m)
82 # print(testtrans)
83
84 # 字符串分割
85 # test = "agetetegwefe"
86 # v = test.partition("e")
87 # v1 = test.rpartition("t")
88 # v2 = test.split("w")
89 # v3 = test.rsplit("f",2)
90 # print(v,v1,v2,v3)
91
92 # 只能根据换行分割 参数 True False 是否显示\n
93 # test = "agetete\ndfaefwe\ndfsfsgwefe"
94 # v = test.splitlines(False)
95 # print(v)
96
97
98 # 大小写相互转化
99 # test = "sofejfoEFI"
100 # v = test.swapcase()
101 # print(v)