Re: [問題] 如何取得系統字元編碼或使用者輸入的編碼?

看板Python作者 (奔跑的蝸牛)時間13年前 (2011/03/15 22:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《mosquito520 ( )》之銘言: : 請教一下各位, : user_input = raw_input(["Search item"]).decode("編碼") : 我需要透過decode將輸入的資料正確的轉成utf8, : 但是在繁中WinXP底下透過sys.getdefaultencoding()取得編碼為Ascii, : 想請教一下, : 假設我希望可以處理多國語言, : 要如何取得正確的編碼順利的轉成utf8呢? : 謝謝:) import sys user_input = raw_input("Please input something: ") print user_input.decode(sys.stdin.encoding).encode('utf8') -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.30.46 ※ 編輯: Holocaust123 來自: 140.112.30.46 (03/15 22:52)
文章代碼(AID): #1DVtq2x- (Python)
文章代碼(AID): #1DVtq2x- (Python)