txt ="郭伊庭 love 蘋果, 蘋果是我 favorite 水果蘋果"
print(txt.count("蘋果"))
print('先練習內建函數len',len(txt))
print('find',txt.find("蘋果"))
print('rfind',txt.rfind("蘋果"))
print("print列印,字串string字元character的組合")
print(txt.lower())
print(txt.title())
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))
字串.方法()
函數LEN(字串)
CHR(字碼)
字串=字元組成
字元 Length Character
.zfill(20) z=zero (20)=填入20個0
.upper() 大寫
.lower() 小寫
.swapcause() 大寫>小寫
case 字體 swaps 交換
Fills the string with a specified number of 0 values at the beginning
Method Description
capitalize() Converts the first character to upper case
casefold() Converts string into lower case
center() Returns a centered string
count() Returns the number of times a specified value occurs in a string
encode() Returns an encoded version of the string
endswith() Returns true if the string ends with the specified value
expandtabs() Sets the tab size of the string
find() Searches the string for a specified value and returns the position of where it was found
format() Formats specified values in a string
format_map() Formats specified values in a string
index() Searches the string for a specified value and returns the position of where it was found
isalnum() Returns True if all characters in the string are alphanumeric
isalpha() Returns True if all characters in the string are in the alphabet
isascii() Returns True if all characters in the string are ascii characters
isdecimal() Returns True if all characters in the string are decimals
isdigit() Returns True if all characters in the string are digits
isidentifier() Returns True if the string is an identifier
islower() Returns True if all characters in the string are lower case
isnumeric() Returns True if all characters in the string are numeric
isprintable() Returns True if all characters in the string are printable
isspace() Returns True if all characters in the string are whitespaces
istitle() Returns True if the string follows the rules of a title
isupper() Returns True if all characters in the string are upper case
join() Converts the elements of an iterable into a string
ljust() Returns a left justified version of the string
lower() Converts a string into lower case
lstrip() Returns a left trim version of the string
maketrans() Returns a translation table to be used in translations
partition() Returns a tuple where the string is parted into three parts
replace() Returns a string where a specified value is replaced with a specified value
rfind() Searches the string for a specified value and returns the last position of where it was found
rindex() Searches the string for a specified value and returns the last position of where it was found
rjust() Returns a right justified version of the string
rpartition() Returns a tuple where the string is parted into three parts
rsplit() Splits the string at the specified separator, and returns a list
rstrip() Returns a right trim version of the string
split() Splits the string at the specified separator, and returns a list
splitlines() Splits the string at line breaks and returns a list
startswith() Returns true if the string starts with the specified value
strip() Returns a trimmed version of the string
swapcase() Swaps cases, lower case becomes upper case and vice versa
title() Converts the first character of each word to upper case
translate() Returns a translated string
upper() Converts a string into upper case
zfill() Fills the string with a specified number of 0 values at the beginning
取得連結
Facebook
X
Pinterest
以電子郵件傳送
其他應用程式
留言
這個網誌中的熱門文章
from tkinter import * #從tkinter函式庫輸入所有函式,檔案'window001.py' import time #412單元延續數入time套件 def delete(): #增加自訂函數def delete() List[int(n.get())-1].destroy() #destroy破壞視窗List[索引] win.config(bg='#BE77FF') b1=Label(win,text='郭伊庭',font='Arial 100 bold',bg='#BE77FF').pack() x=('龍','龓','龕','💩','\U0001F600','\U0001F4A9') #建立元祖tuple名為x,0,1,2,3,4,5 List = [] #建立串列list名為List win=Tk() win.geometry('400x200+800+0') win.title('郭伊庭控制原來的視窗') n = StringVar(win) #類別變數 n.set('刪除') op1 = OptionMenu(win,n,1,2,3,4,5,6).pack() bu1 = Button(win,text='刪除選取視窗',command=delete,font='20',bg='blue',fg='white') bu1.pack() for i in range(6): window = Toplevel() window.title('郭伊庭第%d個視窗' % (i+1)) window.geometry('300x300+%d+%d' % (i*300,i*100)) b1=Label(window,text=x[i],font='Arial 200 bold'...
程式語言編寫,需要編譯器compiler或直譯器interpreter執行。 瀏覽器Chrome或Edge是HTML, CSS, JavaScript的直譯器。 JAVA語言的編譯器是JDK, Java Development Kit爪哇開發工具。 VS Code是撰寫程式的整合開發環境IDE, Integrated Development Environment,可以編寫程式碼,也可以編譯程式,但需要裝Java延伸套件Extension Pack for Java
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]) this=["瘋狗昌","檢舉", "小括號","中"] print(this) for i in range(-1, 4): print(i, this[i])
留言
張貼留言