08 檔案操作

2021-07-13 15:29:06 字數 1469 閱讀 7677

位元組流:inputstream和outputstream

過濾流:bufferedinputstream和bufferedoutputstream

過濾流用於給流增加乙個緩衝的功能,緩衝區越大,效率越高,典型的犧牲空間換時間

08.01.txt

**:public class testtxt }

/** *

寫入文字

* @param filename

完整檔名

* @param list

按行輸入的字串 */

public static voidwritetxt(string filename, listlist)

out.close();

} catch (exceptione) }

/** *

讀取txt

,list

按行返回 */

public static voidreadtxt(string filename, listlist)

input.close();

} catch (exceptione) }

}08.02.excel

**:

public class testexcel }

/** *

讀取excel

中sheet

* @param filename

完整檔名

* @param sheetname

**名

* @param columnnum

讀取的列數

* @param list

按行按列返回的字串 */

public static voidreadsheet(string filename, string sheetname,

int columnnum,list> list)

list.add(ll); }

book.close();

} catch (exceptione) }

/** *

寫入excel

* @param filename

完整檔名

* @param sheetname

**名

* @param sheetnum

表的相對位置

* @param list

按行按列輸入的字串 */

public static voidwriteexcel(string filename, string sheetname, int sheetnum,

list> list) else

sheet.addcell(label); }

rownum++;

linenum = 0; }

book.write();

book.close();

} catch (exceptione) }

}

python08 檔案操作

檔案 1.唯讀 r,rb rb是讀位元組 2.只寫 w,wb 清除之前的東西,重新寫進去內容。3.追加 a,ab 表示寫東西 4.r 讀寫 5.w 寫讀 6.a 寫讀 追加寫讀 我們使用open 函式來開啟乙個檔案,獲取到檔案控制代碼,然後通過檔案控制代碼就可以進行各種各樣的操作了。根據開啟方式的不...

day08 檔案操作

1 三種字串 1 u 普通字串 u abc 預設的文字方式,以字元作為文字的輸出方式 2 b 二進位制字串 b ascii碼 以二進位制 位元組 作為文字輸出方式,且文字內容必須為ascii碼 3 r 原義字串 r n t 將引號中的轉移字串以原本的意義表示出來 多用於檔案路徑的表示 2 檔案操作步...

day08 檔案操作

open 開啟 f 檔案控制代碼 open 檔案的路徑 檔案放的位置 mode 操作檔案的模式 encoding 檔案的編碼 內建函式 f open 蘿莉小姐姐 號 mode r encoding utf 8 print f.read f.close with open 自動關閉檔案 with op...