python调用os.system执行系统命令,中文输出显示乱码

why?


# coding=utf-8

#中文注释
import os
import time

MajorObject = {
                '/cygdrive/e/eBooks/Linux',
                '/cygdrive/e/eBooks/JAVA'}
TargetDir = '/cygdrive/e/eBooks/'

Target = TargetDir + time.strftime('%Y%m%d%H%M%S') + '.tar'
print Target

ZipCmd = "tar -zcvf '%s' %s"%(Target, ' '.join(MajorObject))
print ZipCmd

result = os.system(ZipCmd)

if 0 == result:
    print 'Succeed backup to ', Target
else:
    print 'Backup FAILED'


压缩命令gzip 输出的中文内容,显示为编码:
/cygdrive/e/eBooks/JAVA/Java\272\313\320\304\274\274\312\365(\324\255\312\351\265\3328\260\346)\276\355I_\273\371\264\241\326\252\312\266[www.TopSage.com]/



你可能感兴趣的:(Python)