>Python下使用subprocess中文乱码的解决方案
2015-04-04 21:13
681 查看
# -*- coding: CP936 -*-
import subprocess
cmd="cmd.exe"
begin=101
end=110
while begin<end:
#reload(sys)
#sys.setdefaultencoding('CP936')
p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stdin=subprocess.PIPE,stderr=subprocess.PIPE)
p.stdin.write("echo 你好."+str(begin)+"\n")
p.stdin.close()
p.wait()
print "excution result:\n"
pout=''.join(p.stdout.readlines())
output=pout.decode('cp936').encode('utf-8')
print "%s\n" % output
begin=begin+1
[/code]
来自为知笔记(Wiz)
相关文章推荐
- Python下使用subprocess中文乱码的解决方案
- Python下使用subprocess中文乱码的解决方案
- selenium使用python的csv进行参数化时,中文乱码解决方案
- putty中使用vi中文显示乱码问题的解决方案
- Latex中使用dvipdfm转换方式hyperref包生成PDF中文书签乱码的解决方案
- MFC使用webbrowser时navigate的url中有中文字符,在php服务器端取得的是乱码问题的解决方案
- 【python】蛋疼的中文乱码解决方案
- IE7、IE8下使用escape、encodeURI传递中文参数乱码的问题及解决方案
- SecureCRT中文乱码解决方案(http://www.bootf.com/547.html)-开始学习使用linux
- Struts2中使用GET方式传递中文参数出现乱码的解决方案
- python下的MySQLdb使用+乱码的解决方案
- [Note]关于Python中文编码出现乱码的解决方案(涉及urllib.urlopen(),open()等函数)
- java(jsp)使用MySql数据库,中文乱码的完整解决方案
- 关于使用jsp时出现中文乱码的解决方案总结
- Python的Print打印中文乱码解决方案
- ssh整合时中文乱码的解决方案(使用filter)
- 关于使用jsp时出现中文乱码的解决方案总结
- JQuery中使用Ajax传中文参数乱码解决方案(javaweb开发)
- IE7、IE8下使用escape、encodeURI传递中文参数乱码的问题及解决方案
- Python 中使用 ogr 生成 shape 文件时的中文乱码问题