發表文章
目前顯示的是 4月, 2023的文章
yfinance
- 取得連結
- 以電子郵件傳送
- 其他應用程式
import yfinance as yf msft = yf.Ticker("MSFT") # get all stock info msft.info # get historical market data hist = msft.history(period="1mo") # show meta information about the history (requires history() to be called first) msft.history_metadata # show actions (dividends, splits, capital gains) msft.actions msft.dividends msft.splits msft.capital_gains # only for mutual funds & etfs # show share count # - yearly summary: msft.shares # - accurate time-series count: msft.get_shares_full(start="2022-01-01", end=None) # show financials: # - income statement msft.income_stmt msft.quarterly_income_stmt # - balance sheet msft.balance_sheet msft.quarterly_balance_sheet # - cash flow statement msft.cashflow msft.quarterly_cashflow # see `Ticker.get_income_stmt()` for more options # show holders msft.major_holders msft.institutional_holders msft.mutualfund_holders # show earnings msft.earnings msft.quarterly_earnings # show sustainability msft.sustainability #
(程式)物件導向程式
- 取得連結
- 以電子郵件傳送
- 其他應用程式
一般程式是 變數+函數 物件導向程式是 變數+函數+集合,三者混用 物件導向的集合叫做類別(class),集合裡的單元叫做 物件(object )。 集合裡可以有屬性,且集合裡的物件想當然有這些屬性。 範例來自 : https://www.zetria.org/view.php?subj=programming&chap=3zzmik9mct 現在有一個集合,user , constructor(age, name, level, account, password) , 建立user的屬性。 集合裡面還有一些函數。 /* 宣告類別:使用者 */ 類用戶{ /* 建構物件 */ /* 輸入使用者資料 */ /* 並將其存成屬性 */ constructor(年齡、姓名、級別、賬號、密碼){ 這個。年齡=年齡; this.name = 名稱; this.level = 水平; this.account = 賬戶; this.password = 密碼; } 登錄名(賬號,密碼){ /* 確認帳號密碼正確 */ 如果(賬戶){ 如果(密碼==這個。密碼){ print("登錄成功!"); /* 呼叫greet 方法*/ /* 與使用者打招呼 */ 這個。問候語(); } } } /* 與使用者打招呼 */ 迎接(){ print("歡迎回來,"); 打印(這個。名字); } /* 印出使用者等級 */ 顯示水平(){ 打印(此級別); } /* 將使用者等級加 1 */ 添加級別(){ 這個.level++; } /* 將使用者年齡加 1 */ 添加年齡(){ 這個年齡++; } } 函式多載 允許同一個函數名,輸入不同的變數,輸出不同結果。 範例:C++ 中的函式多載 #include <iostream> int
python 筆記 (一)
- 取得連結
- 以電子郵件傳送
- 其他應用程式
// 商數(整數) ** 次方 != 不等於 b = a[i:j:k] 表示 a[i] 複製到 a[j-1],以 k 的間距取樣。 省略k時,預設為1。 : 表示從a到 b ,空白預設 '0' 或 全部 a=[0,1,2,3] a[1:] >>> [1,2,3] a[:] =a[::] >>>[0,1,2,3] a[1:5] >>> [1,2,3,4] a=list(range(10)) >>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] k<0 從最後開始計算 b=a[:-1] print(b) >>>[0, 1, 2, 3, 4, 5, 6, 7, 8] c=a[2::-1] print(c) >>> [2, 1, 0] d=a[:5:-2] print(d) >>>[9, 7] \n 換行符號,字串中使用。 s='這是第一行\n這是第二行' print(s) >>> 這是第一行 這是第二行 ''' :長引號,按照原有的排版格式存放到字串中 t= '''這是第一行 這是第二行 這是第三行 ''' print(t) >>> 這是第一行 這是第二行 這是第三行 在print ()中 sep 是區隔符號 print (10,20,30,sep=’+’) 多行註解: 在每一行行的開頭加入#,選取多行程式碼區塊後,按下快捷鍵(ctrl+/) 在每一行行的開頭加入#,選取多行程式碼區塊後,按下快捷鍵(ctrl+/)