标签:title tab slow wds imp partition nbsp keyword 填充
1 test = "12"
1 v1 = test.isdecimal() 2 v2 = test.isdigit() 3 v3 = test.isnumeric() 4 print(v1, v2)
True True
1 import keyword 2 print(keyword.iskeyword("def")) 3 test = "def" 4 v = test.isidentifier() 5 print(v)
True
True
1 # \t 制表符 2 # \n 换行符 3 test = "ddfer\thuyb" 4 v = test.isprintable() 5 print(v)
False
1 test = " " 2 v = test.isspace() 3 print(v)
True
1 test = "Adsjdjksdskd jdfksdslkdj" 2 v1 = test.istitle() 3 print(v1) 4 v = test.title() 5 print(v) 6 v2 = test.istitle() 7 print(v2)
False
Adsjdjksdskd Jdfksdslkdj
False
1 test = "你是风儿我是沙" 2 print(test) 3 t = ‘ ‘ 4 v = t.join(test) 5 v1 = ‘_‘.join(test) 6 print(v) 7 print(v1)
你是风儿我是沙
你 是 风 儿 我 是 沙
你_是_风_儿_我_是_沙
1 test = "feng" 2 v = test.ljust(20,"*") 3 v1 = test.rjust(20,"*") 4 v2 = test.zfill(20) 5 print(v) 6 print(v1) 7 print(v2)
feng****************
****************feng
0000000000000000feng
1 test = "Feng" 2 v1 = test.islower() 3 v2 = test.lower() 4 print(v1,v2) 5 v3 = test.isupper() 6 v4 = test.upper() 7 print(v3,v4)
False feng
False FENG
1 test = " \nfeng " 2 v = test.lstrip() 3 v1 = test.rstrip() 4 v2 = test.strip() 5 print(v,v1,v2)
feng
feng feng
1 v = "saevdds;gfuiuyv;sdiujsd" 2 m = str.maketrans("aeiou", "12345") 3 new_v = v.translate(m) 4 print(new_v)
s12vdds;gf535yv;sd35jsd
1 test = "testuufuskjksdkd" 2 v = test.partition(‘s‘) # 最多分割成三分 3 v1 = test.rpartition(‘s‘) 4 v2 = test.split(‘s‘,2) 5 v3 = test.rsplit(‘s‘,3) 6 print(v, v1, v2, v3)
(‘te‘, ‘s‘, ‘tuufuskjksdkd‘) (‘testuufuskjk‘, ‘s‘, ‘dkd‘) [‘te‘, ‘tuufu‘, ‘kjksdkd‘] [‘te‘, ‘tuufu‘, ‘kjk‘, ‘dkd‘]
1 test1 = "wdsdsfd\nsdfdfg\ncadewefq\nsd" 2 v4 = test1.splitlines(True) 3 print(v4)
[‘wdsdsfd\n‘, ‘sdfdfg\n‘, ‘cadewefq\n‘, ‘sd‘]
1 test = "backend 1.1.1.1" 2 v = test.startswith("a") 3 print(v) 4 v1 = test.endswith(‘a‘) 5 print(v1)
False
False
1 test = "feng" 2 v = test.swapcase() 3 print(v)
FENG
标签:title tab slow wds imp partition nbsp keyword 填充
原文地址:https://www.cnblogs.com/fengpiaoluoye/p/9350762.html