Created
February 1, 2022 08:54
-
-
Save Keycatowo/9c73e5c87bb2fc21dfca3de176b99e8b to your computer and use it in GitHub Desktop.
讀取txt並進行簡單逐行處理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 讀取txt並進行簡單逐行處理 | |
with open("filename.txt", "r") as f: | |
text = f.read() # 一次讀取 | |
lines = f.readlines() # 按行讀取 | |
data = [line.strip().split(",") for line in lines] # 去頭尾符號,以,分割成list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment