官詳和w3schools字串str,format,slicing[::]
w3chools
程式碼
#官詳和STRINGS可以用單引雙引只要對稱
b = "貓抓鼠,狗吃屎,兔吃草,任昌很帥"
# 0 1 2 3 4 5 6 7 8 9 10,11,12,13,
print('字串長度'+str(len(b)))
#len函數 字串長度 輸出 整數
#str函數 轉成字串 這樣才能串接
print(b[-5:-1])
#練習字串格式format
quantity = "精華下午茶"
itemno = 5
price = "官詳和"
myorder = "我要吃 {} 吃幾個 {} ,和 {} 誰一起吃"
print(myorder.format(quantity, itemno, price))
留言
張貼留言