[問題] python 2.6 中的中文處理

看板Python作者 (raison detre)時間15年前 (2009/12/21 15:02), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串1/1
請問一下各位前輩 小弟用的是python 2.6 再處理中文的時候會有問題 以下為程式碼範例 # -*- coding: utf-8 -*- import os listDoc2 = os.listdir('c:\\test2') print listDoc2 szParam_2 = 'C:\\公司軟體' print szParam_2 listDoc = os.listdir(szParam_2) print listDoc print listDoc2 的時候如果裡頭的檔名有中文的話無法正常顯示 print szParam_2 的時候正常 listDoc = os.listdir(szParam_2) 則編譯的時候會有錯誤 請問除了用python 3.0 之外 是否還有好的解決方式 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.220.110.100

12/21 15:41, , 1F
在linux下測試沒問題阿 @@?
12/21 15:41, 1F

12/21 15:42, , 2F
如果用 for i in listDoc2: print i 呢?
12/21 15:42, 2F

12/21 15:46, , 3F
u'C:\\公司軟體'
12/21 15:46, 3F
文章代碼(AID): #1BBnrrlg (Python)
文章代碼(AID): #1BBnrrlg (Python)