發表文章

方逵python自訂函數圈write模式a與w

圖片
vs code 截圖 期中考筆記重點 write寫入檔案模式mode w=write會覆蓋原有檔案, a=append接續原來檔案, x=create創立新檔案, x與w有何不同? write寫入檔案,預設不換行,換行'\n' print呈現在螢幕,預設換行,不換行end=''。 write寫入用到英文以外的字元(一,a,b)encoding='utf8' 386

方逵開啟資料夾編寫檔案

圖片
VS code開發環境截圖 381 382 space, slash, backslash, cr = ' ', '/', '\\', '\n' k = input('輸入規格: ') m = input('輸入橫向規格: ') k, m = int(k), int(m) #將字串k轉integer整數 f = open("方逵.txt",'w',encoding="utf8") for i in range(1, k+1): 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('\n') f.close()

方逵python檔案files方法methods

圖片
f = open("ascii.txt", "r") #註解開啟open檔案ascii.txt讀取模式r開啟之後要關閉 x = f.read() f.close() print("檔案長度", len(x)) print("列印內容",x) f = open("ascii.txt", "r") y=f.readlines()#輸出成串列,長度是列數 print("串列y的長度",len(y)) for i in range(len(y)): print("第",i+1,"列",y{i})

方逵python內建函數built-in函數function迴圈loop範圍range

圖片
w3schools內建函數列表 https://www.w3schools.com/python/python_ref_functionsasp  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 ascii() Returns a readable version of an object. Replaces none-ascii characters with escape character bin() Returns the binary version of a number bool() Returns the boolean value of the specified object bytearray() Returns an array of bytes bytes() Returns a bytes object callable() Returns True if the specified object is callable, otherwise False chr() Returns a character from the specified Unicode code. classmethod() Converts a method into a class method compile() Returns the specified source as an object, ready to be executed complex() Returns a complex number delattr() Deletes the specified attribute (property or method) from the specified object dict() Returns a dictionary (A...

方逵python字串string內建built-in方法methods

圖片
VS code開發環境w3schools截圖 字串程式碼 a= "Ha,方逵很handsome,很讚!很棒!我使用w3schools學習,也會使用vscode開發環境" b= a.replace('讚','帥') print(a) print(b) print('幾個很?',a.count('很')) print('很在0,1..位置',a.find('很')) print('很在0,1..位置',a.rfind('很')) print('a的長度',len(a)) print('英文大寫',a.upper()) print('英文大寫',a.lower()) txt = "HELLO, 將第一個字母轉成大寫。" x = txt.capitalize() print (x) print (txt.casefold()) y=txt.center(30) print(txt.center(30)) print(y) print(len(y))

方逵java程式設計

圖片
import java.awt.*; import java.awt.geom.Line2D; import javax.swing.*; public class Options { public static void main(String[] args) { JFrame frame = new JFrame("劉任昌Java繪製選擇權到期日損益"); Container cp = frame.getContentPane(); cp.add(new JComponent() { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(2));//stroke中風,筆觸 g2.setColor(Color.cyan); g2.setFont(new Font("monospaced", Font.BOLD|Font.ITALIC , 30)); g2.drawString("買入賣權到期日損益",0,120); g2.draw(new Line2D.Float(0, 0, 100, 100)); g2.draw(new Line2D.Float(100, 100, 200, 100)); g2.drawString("買入買權到期日損益",300,120); g2.draw(new Line2D.Float(300, 100, 400, 100)); g2.draw(new Line2D.Float(400, 100, 500, 0)); g2.drawString("賣出賣權到期日損益...

方逵w3chool繪圖,canvas,svg,

圖片
canvas繪圖套件繪製選擇權到期日損益圖 買入選擇權到期日損益 賣出選擇權到期日損益 w3schools學習canvas繪圖 Your browser does not support the HTML canvas tag. w3schools學習svg繪圖 JAVA期末考 VScode安裝編輯java的延伸套件Extension pack for java 心得 Java的每一個元件或議題,都會扯上類別(class)與物件(object),且都有屬性與方法(method)。