1. 程式人生 > 其它 >The injection point has the following annotations: - @org.springframework.beans.factory.annotation.

The injection point has the following annotations: - @org.springframework.beans.factory.annotation.

#字串1
#輸入
#字串的大小寫轉換
#capitalize(首字母大寫),casefold(所有字母小寫),title(每個單詞首字母大寫),
# swapcase(小寫大寫轉換),upper(所有字母大寫),lower(所有字母小寫)
#左中右對齊方法
#center(width,fillchar='')(居中) ljust(width,fillchar='')(左對齊)
#  rjust=(width,fillchar='')(右對齊)  zfill(width)()(處理數字)
#fillchar=''就是填充字元(填充只能填充一個字元,
# The fill character must be exactly one character long)
x="yoU a but" print(x.capitalize())#You a but print(x.casefold())#you a but print(x.title())#You A But print(x.swapcase())#YOu A BUT print(x.upper())#YOU A BUT print(x.lower())#you a but print(x.center(15))# you a but print(x.ljust(15))#you a but print(x.rjust(15))# you a but y="404" print(y.zfill(5))#
00404 print(x.center(20,""))#啊啊啊啊啊yoU a but啊啊啊啊啊啊 #字串2 #字串查詢 count(字元,開始,結束)(開始與結束為索引號) #find(字元,開始,結束)(從左往右),rfind(字元,開始,結束)(從右往左) #index(字元,開始,結束)(索引)(從左往右),rindex(字元,開始,結束)(從右往左) t="上海自來水來自海上" print(t.count(""))#2 print(t.count("",0,5))#1 print(t.find(""))#1 print(t.rfind(""))#7 #當查詢時出現字串中沒有的值時,find與index的處理方式,不一樣,find與rfind會返回-1
#而index會出現報錯 print(t.rfind(""))#-1 print(t.index(""))#0 print(t.rindex(""))#8 #t替換:expandtabs([tabsize=8])(使用空格替換字表符), # replace(old,new,count=-1),translate(table) code=""" print("I love you") print("i do not know") """ newcode=code.expandtabs(4) print(newcode)# print("I love you") # print("i do not know") code2="哇哦,真實啊!" newcode2=code2.replace("哇哦","可怕") print(newcode2)#可怕,真實啊! #字串靜態方法 table=str.maketrans("你是ab","1234") shabi="你是傻逼".translate(table) print(shabi)#12傻逼 shabi="你是傻逼".translate(str.maketrans("你是ab","1234","")) print(shabi)#12傻 #字串格式化 print("{0} {1} ni".format("",""))#我 三 ni print("{{0}}".format("支付寶"))#{0} print("{0:.1f}{1}".format(27.678,"GB"))#27.7GB #acsll碼值%c g="%c,%c,%c"%(97,98,99) print(g)#a,b,c #格式化字串%s g='%s'%'I you' print(g) #格式化整數%d g="%d+%d=%d"%(1,2,1+2) print(g)#1+2=3 #格式化無符號八進位制數%o g='%o'%10 print(g)#12 #格式化無符號十六進位制數%x g='%x'% 10 print(g)#a #格式化無符號十六進位制數%X g='%X'% 160 print(g)#A0 #格式化定點數,可指定小數點後的精度%f g='%f'% 3.145 print(g)#3.145000(浮點數精確六位) #科學計數法格式化定點數%e g='%e'% 3.145 print(g)#3.145000e+00(浮點數精確六位) g='%E'% 3.145 print(g)#3.145000E+00(浮點數精確六位) #根據值的大小決定使用%f還是%e g='%g'% 3.145 print(g)#3.145 g='%G'% 3.145 print(g)#3.145 #格式化操作輔助命令 #m.n,m是顯示的最小總寬度,n是小數點後的位數 g='%5.1f'% 3.145 print(g)# 3.1 #左對齊- g='%-1d'% 3.145 print(g)# 3 #正數前顯示+ g='%+10d'% 3.145 print(g)# +3