發表文章

陳暐丞eval=evaluate函數calculator美國男生印度女生,調色版

圖片
w3schools eval() 美國男生Bro Code from tkinter import * def button_press(num): global equation_text equation_text = equation_text + str(num) equation_label.set(equation_text) def equals(): global equation_text try: total = str(eval(equation_text)) equation_label.set(total) equation_text = total except SyntaxError: equation_label.set("syntax error") equation_text = "" except ZeroDivisionError: equation_label.set("arithmetic error") equation_text = "" def clear(): global equation_text equation_label.set("") equation_text = "" window = Tk() window.title("Calculator program") window.geometry("500x500") equation_text = "" equation_label = StringVar() label = Label(window, textvariable=equation_label, font=('consolas',20), bg="white", width=24, height=2) label.pack() ...

python視窗建構Toplevel與Tk比較

圖片
mainloop() pre 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='red') b1=Label(win,text='陳暐丞',font='Arial 100 bold',bg='#0000ff').pack() x=('幹','你','娘','💩','?','\U0001F4A9') #建立元祖tuple名為x,0,1,2,3,4,5 List = [] #建立串列list名為List win=Tk() #建構子 constructor 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('300x250+%d+%d' % (i*300,i*50)) b1=Label(window,text=x[i],font='A...

陳暐丞tkinter繪圖套件time時間sleep方法

圖片
from tkinter import * #下載程式碼,從tkinter輸入所有函式 x = ['\U0001F600','\U0001F601','\U0001F602','\U0001F603','\U0001F604']#定義一個串列 for i in range(5): window = Tk() #建構視窗,名為window建構一個房子 window.title('陳暐丞第%d視窗' % (i+1)) window.geometry('400x400+%d+%d' % (400*i, i*100)) b1=Label(window,text=x[i],font='Arial 250 bold').pack() window.mainloop()

陳暐丞期中考emoji繪文字onchange事件

圖片
陳暐丞輸入參數 輸入k 輸入m 輸入n 執行自訂函數 red green blue 重點 span手掌張開拇指到小指,短橋梁長度。 VSCode是IDE整合開發環境。 CTRL+SHIFT+L一次改全部 Integrated Development Environment alert內建函數,自訂函數abc 利用id加上syle方法是#id 老師的公民記者 https://www.peopo.org/news/672998 陳暐丞輸出結果

陳暐丞python與JAVASCRIPT程式碼對照

圖片
h1{background-color: purple; color: white; border: 10px solid red; text-align:center; padding: 5px} ul{background-color: green; color: white; font-size: 2em;line-height:1.5} input{font-size:24px;background-color:rgb(210, 250, 215);} .monkey{font-size:36px;} pre{background-color: purple; color: white;} 陳暐丞輸入參數 輸入k 輸入m 輸入n 執行自訂函數 重點 alert內建函數,自訂函數abc 陳暐丞輸出結果

陳暐丞python寫入write迴圈範圍range

圖片
space, slash, backslash, cr = ' ', '/', '\\', '\n' k = input('邊長: ') #輸入字串 m = input('橫向: ') k, m = int(k), int(m) f = open("難嗎.txt",'w',encoding='utf8') f.write('劉任昌讀取檔案' + cr)#註解\n換列 for i in range(9): f.write(str(i)) f.write(cr) for i in range(1, k+1): #迴圈1到k for ii in range(m): for j in range(k-i): f.write(space) f.write(slash) for j in range(2*i-2): f.write(space) f.write(backslash) for j in range(k-i): f.write(space) f.write(cr) for i in range(1, k+1): for ii in range(m): for j in range(i-1): f.write(space) f.write(backslash) for j in range(2*k-2*i): f.write(space) f.write(slash) for j in range(i-1): f.write(space) f.write(cr) f.close()

陳暐丞python字串string方法methods

圖片
單元371影片 程式碼 txt = "陳暐丞 love 蘋果, 蘋果是我 are my favorite 水果蘋果" print(txt.count("蘋果")) print('先練習內建函數len',len(txt)) print('find',txt.find("蘋果")) print(''rfind',txt.rfind("蘋果")) 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 isalph...