源目錄:input 中有數萬個gbk文件,但在linux系統下gbk是亂碼,可使用python的decode 和encode進行轉換,也可使用c語言中iconv.h 進行轉碼,還可使用shell命令 iconv 進行轉碼python
iconv -f 原編碼 -t 目標編碼 輸入文件 > 輸出文件linux
對於這個問題採用的完整語句爲:shell
ls input/ | xargs -I {} sh -c "iconv -f gb18030 -t utf-8 input/{} > output/{}"編碼
注意:輸入目錄和輸出目錄是兩個不一樣的目錄,不然 就會變成空文件!!!code