曹采臻python字串string內建built-in方法methods

VSCODE開發環境w3school截圖

字串程式碼

a = "Ha,曹采臻很餓,很想吃飯我使用w3school學習,也會使用VSCODE開發環境"
b = a.replace('餓','想吃飯')
print (a)
print (b)
print('幾個很?', a.count('很'))
print('很在0.1..位置', a.find('很'))
print('很在0.1..位置', a.rfind('很'))
print ('a的長度',len(a))
print ('英文大寫',a.upper())
print ('英文小寫',a.lower())
txt = "HELLO,將第一個字母轉成大寫"

x = txt.capitalize()

print (x)
print (txt.casefold())
y = (txt.center(30))
print(txt.center(30))
print (y)
print (len(y))

這個網誌中的熱門文章

曹采臻蒙地卡羅模擬資產價格

曹采臻產業分析雲端運算網路服務

曹采臻python類別class函數def