--- title: 7.文字檔案的編碼格式與文字檔讀取方法 tags: Python 進階語法與應用, 筆記 --- pycharm 不要用記事本 pycharm ->new ->file->檔名a.txt 文字處理 ----哈囉 編碼 ----01000011110101010 解碼 ----哈囉 ---- 亂碼:編碼方式不等於解碼方式 以前: 英文ASGI 中文BIG-5 簡體GBK --- 現在 萬國編碼 utf-8 --- 作業系統預設編碼 1.非windows :utf-8 2.windows:預設用ANSI 編碼(words, 記事本) --- 用pycharm都是用utf-8儲存 f=open("data1.txt","r", encoding="utf-8") #唯獨模式r 只能讀不能寫/encoding不管讀或寫都要寫 article=f.read() f.close() print(article) ## END
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up