陳映年w3schools字串str, format, slicing[::]
w3schools
程式碼
#陳映年strings可以用單引雙引只要對稱
b = '123,456,789'
# 0 1 23 4 5 678 9 10,11,12
print('字串長度' + str(len(b)))
#len函數 字串長度 輸出 整數
#str函數 轉成字串 這樣才能串接
print(b[-5:-2])
#練習字串格式format
quantity = "日k"
itemno = 3
price = "朋友"
myorder = "我要去 {} 唱幾小時 {} 和 {} 一起唱"
print(myorder.format(quantity, itemno, price))
心得:
這次的課程蠻有趣的。
留言
張貼留言