作者ireullin (raison detre)
看板Python
標題[問題] python 2.6 中的中文處理
時間Mon Dec 21 15:02:11 2009
請問一下各位前輩
小弟用的是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
推 borting:在linux下測試沒問題阿 @@? 12/21 15:41
→ borting:如果用 for i in listDoc2: print i 呢? 12/21 15:42
推 StubbornLin:u'C:\\公司軟體' 12/21 15:46