网站建设与开发做什么,南京模板建站,wordpress 加子目录,网上商城网站源码#value raitOrEi#v value.capitalize()#首字母大写#print(v)#v1 v.casefold()#全部变小写#xff0c;不只是英文的#xff0c;其他语言特殊的大小写也变换#print(v1)#v2 v.lower()#只是英文变小写#print(v2)#设置宽度#xff0c;并将内容居中#20 代指总长度…#value raitOrEi#v value.capitalize()#首字母大写#print(v)#v1 v.casefold()#全部变小写不只是英文的其他语言特殊的大小写也变换#print(v1)#v2 v.lower()#只是英文变小写#print(v2)#设置宽度并将内容居中#20 代指总长度#只能填充一个字符,字符可有可无没有字符用空格填充#value raitorei#v value.center(20)#print(v)#v1 value.center(20,*)#print(v1)#v2 value.ljust(20,*)#print(v2)#v3 value.rjust(20,*)#print(v3)#v4 value.zfill(20)#只能用0填充#print(v4)#去字符串中寻找寻找子序列的出现次数#value reraitorei#v1 value.count(re)#v2 value.count(re,5)#v3 value.count(re,5,6)#起止位置#print(v1)#print(v2)#print(v3)#encode#decode#以什么开始#以什么结尾#test raitorei#v test.startswith(r)#print(v)#v test.endswith(i)#print(v)#把字符串中的 tab 符号(\t)转为空格tab 符号(\t)默认的空格数是 8.#具体规则是括号里是多少以这个数字为一组如果是开头空格占位数字多少。比如#test 123\t456789#v test.expandtabs()#123 456789 8个一组空格补缺少的位置#print(v)#v1 test.expandtabs(6)#123 456789 6个一组空格补缺少的位置#print(v1)#从开始往后找找到第一个之后获取位置#大于等于开始小于结束未找到 -1#test rei#v test.find(r,0,2 )#print(v)#index找不到报错 忽略#test rei#v test.index(a)#print(v)#将一个字符串中的占位符替换为指定的值#test Im {name}, age {a}#print(test)#v test.format(nameraitorei,a22)#print(v)#将一个字符串中的占位符替换为指定的值,字典#test Im {name}, age {a}#print(test)#v test.format_map({name: raitorei, a: 22})#print(v)#星号 字符串中是否只包含字母数字汉字#test fdfd1f风动旛动3#v test.isalnum()#print(v)#星号 判断字符串中是否只包含字母数字汉字#test fdfdf风动旛动#v test.isalpha()#print(v)#判断字符串中是否是数字#test 123②#v test.isdecimal()#②特殊的不可以#v1 test.isdigit()#二中文的数字不支持#v2 test.isnumeric()#print(v,v1,v2)#数字 字母 下划线 标识符def class#test a123#v test.isidentifier()#数字开头false#print(v)#数字 字母 下划线 标识符def class#test a123#v test.isidentifier()#数字开头false#print(v)#是否存在不能打印的字符比如\t,结果是false#test a\t123#v test.isprintable()#print(v)#判断是否全部是空格#test \t#v test.isspace()#print(v)#判断是否是标题#test the loneliest girl#v test.istitle()#print(v)#v1 test.title()#print(v1)#v2 v1.istitle()#print(v2)#***** 加入字符#test _#value raitorei#v test.join(value)#等于.join(value)#print(v)#islower() 方法检测字符串是否由小写字母组成。#isupper() 方法检测字符串中所有的字母是否都为大写。#test1 abc#test2 abc123#test3 abc123A#v1 test1.islower()#v2 test2.islower()#v3 test3.islower()#print(v1,v2,v3)#test4 ABC#test5 ABC123#test6 ABC123a#v4 test4.isupper()#v5 test5.isupper()#v6 test6.isupper()#print(v4,v5,v6)#变换大小写#test asdfgh#v test.upper()#print(v)#v v.lower()#print(v)#默认去除左右空格,\t,\n可以指定字符#test a s fgh #v test.lstrip()#print(v)#v test.rstrip()#print(v)#v test.strip()#print(v)#v1 v.strip(h)#print(v1)#变换大小写#test asdfgh#v test.maketrans(asd,123)#print(v)#v1 test.translate(v)#print(v1)#分割字符partition包含分隔符split不包含分隔符#test asdfghasdfghasdfgh#v1 test.partition(f)#print(v1)#v2 test.rpartition(f)#print(v2)#v3 test.split(f,2)#print(v3)#v4 test.rsplit(f,2)#print(v4)#分割换行符默认不包含分隔符(false)true包含分隔符#test asdfg\nhasd\nfghasdfgh#v1 test.splitlines(True)#print(v1)#分割换行符默认不包含分隔符(false)true包含分隔符#test asdfg\nhasd\nfghasdfgh#v1 test.splitlines(True)#print(v1)#大小写转换#test asdfghJKL#v1 test.swapcase()#print(v1)#替换test asdfghaJKaL#v1 test.replace(a,b)#print(v1)#v2 test.replace(a,b,2)#print(v2)################基本(7个)#################join#split#find#strip#upper#lower#replace################灰魔法(5个)################test raitorei##索引#v1 test[0]#print(v1)##切片#v2 test[0:-1]#print(v2)##长度#v3 len(test)#print(v3)#li [1,2,3,4,5,123]#print(len(li))#循环输出#index 0#while index len(test) :#print(test[index])#index 1#print(---end---)#for demo in test:#print(a)#帮助创建数字,可以设置隔多少再创建#v range(0,100,5)#print(v)#for vv in v:#print(vv)#将输入的文字的索引输出value input()lengthlen(value)numrange(0,length)for f innum:print(f,value[f])#*****注意#字符串一且自,不可修改。#一且修改或者拼接,部会造成重新生成字符串