shell命令:iconv
iconv --list # 显示可识别的编码名称
iconv --list >./infomation.log # 显示可识别的编码名称,将信息存入infomation.log文件中
iconv -f GB2312 -t UTF-8 a.html > b.html # 转换GB2312编码的文件a.html为UTF-8编码,存入b.html
iconv -f GB2312 -t BIG5 a.html > b.html # 转换GB2312编码的文件a.html为BIG5编码,存入b.html
进入正题,我们先cd进入保存所有文件的文件夹,然后执行下列命令:
find *.py -exec sh -c "iconv -f GB18030 -t UTF8 {} > {}.py" \;
上面命令中的GB18030,如果你转换前的编码为GB2312,将 GB18030 代替为 GB2312 即可。