w3schools字串slicing[::],str,len

w3schools

程式碼

樣式style
#江紫恩strings可以用單引雙引只要對稱
b = '狗吃屎,兔吃菜,貓抓鼠'
#    0 1 23 4 5 678 9 10,11,12,
print('字串長度' + str(len(b)))
#len函數 字串長度 輸出 整數
#str函數 轉成字串 這樣才能串接
print(b[-5:-2])
#練習字串格式format
quantity = "滿漢大餐"
itemno = 5
price = "江紫恩"
myorder = "我要吃 {} 吃幾個 {},和 {} 誰一起吃"
print(myorder.format(quantity, itemno, price)) 

字串的方法與函數w3schools

https://www.w3schools.com/python/python_strings_methods.asp

留言

這個網誌中的熱門文章

D11117113江紫恩期末考

江紫恩tkinter視窗函式庫Entry工具widget