林佳昀python字串string內建built-in方法methods

VS Code開發環境w3schools截圖

字串程式碼

a = "ha,老師很handsome,很變態!我使用w3school學習,也會使用vsCode開發環境"
b = a.replace('變態','瀟灑')
print (a)
print (b)
print ('幾個很?',a.count('很'))
print('很再0,1..位置',a.find('很'))
print('很再0,1..位置',a.find('很'))
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))

留言

這個網誌中的熱門文章

林佳昀投資學股利成長模型

林佳昀投資學股利折現模式本益比

2025年一月投資學期末考