#Python 檔案讀取file.read(), file.readlines(), file.readline()
“””
read.txt內容:
Hello! World!
哈囉!世界!
1 2 3 4 5
with open( ) as file:
會自動關閉檔案
最末可以少打
file.close()
“””

“””
使用.readlines()
跟.read() 一樣
都是讀取全部的資料
差別是 .readlines()
\n的換列字元也會涵蓋
而且回傳一個list
“””

“””
file.readline()
只有讀取一行
“””

“””
read.txt內容:
Hello World
中文
1 2 3 4 5 6
“””
#使用以下方式去掉\n:



![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python 進階實戰:深入 Word 核心,挖出那一坨 BLOB (含自省 Debug 技巧, BLOB= Binary Large Object) ; part = doc.part.rels[rid].target_part ; return part.blob if “ImagePart” in type(part).__name__ else None Python 進階實戰:深入 Word 核心,挖出那一坨 BLOB (含自省 Debug 技巧, BLOB= Binary Large Object) ; part = doc.part.rels[rid].target_part ; return part.blob if “ImagePart” in type(part).__name__ else None](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2026/01/20260126111046_0_cd8751.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言