python中的system函数与编码

在调用os.system执行命令时,发现system不能接受unicode的命令。那么命令中却又包含以unicode表示的中文等字符怎么办?

——方法就是将unicode转化为utf8

path = u'我的文件.txt'
cmd = 'process'
cmd += ' '+ path.encode('utf8')
os.system(cmd)

 

posted on 2015-01-22 15:05  rainduck  阅读(768)  评论(0编辑  收藏  举报

导航