這個網誌中的熱門文章
張佑維python,print,input,字串方法[::-1]
w3schools 微軟Visiual Studio Code編寫python程式 微軟Visiual Studio Code編寫python程式碼 #註解:張佑維2023/02/20 print("在Dcard出征張佑維") a="一二三四五六七八九" print(a) b=a[2:9:]#方法取字串a第3到第8字元 print(b) c=a[2:9:2] print(c) d=a[9:2:-1] print(d) a = input("輸入字串: ") print("原來字串: "+a) b = a[::-1] print("反向字串: "+b) 心得 Python的設計哲學,強調程式碼的可讀性和簡潔的語法,尤其是使用空格縮排來劃分程式碼塊。相比於C或Java,Python讓開發者能夠用更少的代碼表達想法。
張佑維Entry輸入文字變數textvariable字型font
將OptionMenu改成Entry 將OptionMenu改成Entry完整程式碼 from tkinter import * #從函式庫 tkinter 輸入所有 * 方法 import math #從函式庫 math 輸入所有 * 方法 from time import * from random import * class Regular: def __init__(self, cx, cy, cr, s, t, c, w): #類別共同的設定必然 def __init__ initiate發起 self.cx, self.cy, self.cr = cx, cy, cr #取得中心座標cx, cy, 半徑cr self.s, self.t = s, t #取得邊角數目s,t尖銳程度,取代原來的k = s.get() self.c, self.w = c, w #取得顏色c,寬度w self.u = 2 * math.pi / self.s #使用模組 math 圓周率 pi self.x, self.y = [], [] for i in range( int(self.s * 1.5)): self.x.append(self.cx + self.cr*math.cos(i*self.u)) self.y.append(self.cy + self.cr*math.sin(i*self.u)) def drawLine(self, x0, y0, x1, y1): canvas.create_line(x0, y0, x1, y1, width = self.w, fill=self.c) def draw(self): #類別的方法 secondTime = second.get() #取得輸入的second變數,當作區域變數secondTime for i in range( int(self.s * 1.5)
留言
張貼留言