python调用os.system执行系统命令,中文输出显示乱码
2013-11-19 20:08
706 查看
why?
压缩命令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]/
# 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基础之使用os.system来执行系统命令
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令,os.system && os.popen && subprocess.Popen
- Python执行系统命令的方法 os.system(),os.popen(),commands
- [转] Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python借助os.system,subprocess.call()函数调用系统命令
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- Python执行系统命令的方法 os.system(),os.popen(),commands
- python执行系统命令的方法:os.system(), os.popen(), subprocess.Popen()
- Python——cmd调用(os.system阻塞处理)(多条命令执行)
- pycharm下 os.system os.popen执行命令返回有中文乱码
- Python执行系统命令的方法 os.system(),os.popen(),commands