标签:art 格式化 位置 isa col 设置 数据类型 index 字母
1 test = "feng" 2 首字母大写 3 v = test.capitalize() 4 print(v)
1 v1 = test.casefold() 2 print(v1) 3 v2 = test.lower() 4 print(v2)
1 # 20 代指总长度 2 # * 空白未知填充,一个字符,可有可无 3 v = test.center(20,"中") 4 print(v)
>>>中中中中中中中中feng中中中中中中中中
1 test = "fengfeng" 2 v = test.count(‘en‘) 3 print(v) 4 5 test = "fengfeng" 6 v = test.count(‘en‘,5,7) 7 print(v)
1 test = "feng" 2 v = test.endswith(‘en‘) 3 v = test.startswith(‘en‘) 4 print(v)
1 test = "feng" 2 #未找到 -1 3 v = test.find(‘en‘) 4 print(v) 5 6 test = "feng" 7 v = test.index(‘feng‘) 8 print(v)
1 test = ‘i am {name}, age {a}‘ 2 print(test) 3 v = test.format(name=‘feng‘,a=19) 4 print(v) 5 6 test = ‘i am {0}, age {1}‘ 7 print(test) 8 v = test.format(‘feng‘,19) 9 print(v) 10 11 #格式化,传入的值 {"name": ‘feng‘, "a": 19} 12 test = ‘i am {name}, age {a}‘ 13 v1 = test.format(name=‘df‘,a=10) 14 v2 = test.format_map({"name": ‘feng‘, "a": 19})
1 test = "123" 2 v = test.isalnum() 3 print(v)
标签:art 格式化 位置 isa col 设置 数据类型 index 字母
原文地址:https://www.cnblogs.com/fengpiaoluoye/p/9347606.html