→ kilfu0701:u'I://新文字文件.txt'.encode("big5") ? 12/06 10:15
→ uranusjr:Windows sucks... 12/06 10:17
→ CMJ0121:我猜 你應該是要轉big5才對 我手邊win7是用big5編碼 12/06 10:20
→ LearnRPG:1F:這樣是可以的!! 2F:我也知道啊(哭 3F:感謝 12/06 10:24
→ LearnRPG:但是要是我的測試這邊改成 日文あいうえお.txt呢?? 12/06 10:24
→ LearnRPG:因為畢竟是想利用 utf-8 的編碼去開檔避開各語系問題 12/06 10:25
→ LearnRPG:還是利用big5的話可以開但是會有空白 我不想裝補完計畫 12/06 10:28
→ bob123:修改lib/subprocess.py就可 3.x應該就沒這問題了吧 12/06 10:44
依照 bob大提供的這頁修改
http://bugs.python.org/file11674/Python-2.5.2-subprocess.patch
exe = 'notepad.exe'
param = u"測試.txt"
subprocess.Popen([exe, param], stdout=subprocess.PIPE).communicate()[0]
不用加上 .encode('big5') 就可以正確了
但是還是卡在要是檔名有 非 big5 (例如日文語系)就不行
依然出現檔案名稱、目錄名稱或磁碟區標籤語法錯誤
加上 .encode('big5') 則開啟" .txt" ...
這原因是不是出在 windows 在系統編碼上不是用 unicode ...?
但是自己去檔案總管開又可以開 所以想說是不是 python 有可用的方法
※ 編輯: LearnRPG 來自: 140.127.194.130 (12/06 11:18)
→ LearnRPG:回報一下 依照 bob 的 3.x 沒這問題我去使用 python3.3 12/06 11:31
→ LearnRPG:可以很直覺的使用了 太感謝大家了 !!! 12/06 11:32
推 AlanSung:encode(sys.stdin.encoding) 試看看? 12/07 08:07