txt = "沈甄軒 love 木瓜, 木瓜是我 are my favorite 水果木瓜"
print(txt.count("木瓜"))
print('先練習內建函數len',len(txt))
print('find',txt.find("木瓜"))
print('rfind',txt.rfind("木瓜"))
print("print列印,字串string字元character的組合")
print(txt.title())
print(txt.lower())
print(txt.upper())
print(txt.swapcase())
print(txt.zfill(32))
print(txt.startswith("軒"))
print(len(txt))
for i in range(33333, 33344):
print(chr(i))
for i in range(65, 70):
print(chr(i))
程式碼 print(int(10)) print(int("ff",16)) print(int('100',16)) print(int('100',8)) a = [0>1, 2>1, 3==3]#串列list使用square bracket中括號 print("是否all全真",all(a)) print("存在任何any一個真",any(a)) print("沈甄軒bin二進位輸出一到9") for i in range(10): #0 to 9進位1 print(bin(i)) for i in range(0, 200, 10): print(hex(i)) a = ('蘋果', '香蕉', '櫻桃',"durian") b = "Hello World" c = 33 d ={'蘋果', '香蕉', '櫻桃',"durian"} e=['蘋果', '香蕉', '櫻桃',"durian"] print("a元組typle", type(a)) print("b字串", type(b)) print("c整數integer", type(c)) print(type(d), type(e)) w3school vs code截圖 w3school內建函數列表 Python has a set of built-in functions. Function Description abs() Returns the absolute value of a number all() Returns True if all items in an iterable object are true any() Returns True if any item in an iterable object is true a...
this=["於末姚","檢舉", "小","中"] that=("元組","tuple","貓","兔","狗") print(this) for i in range(-4, 4): print(i, this[i]) for i in range(-5, 5): print(i, that[i])
第一次字串方法,很優秀,妳是女神!https://shenzhenxuan.blogspot.com/2024/02/pythonstringmethods.html
回覆刪除