Python下使用subprocess中文乱码的解决方案
来源:互联网 发布:淘宝以前的订单消失了 编辑:程序博客网 时间:2024/06/07 19:08
分类:
http://blog.sina.com.cn/s/blog_567002510101c516.html
http://www.cnblogs.com/bsmagic/p/4392928.html
1、window上使用shell显示中文
reload(sys)sys.setdefaultencoding('utf-8')
2、cybiwn pycharm 中显示中文
output = line.decode('cp936').encode('utf-8') print "%s\n" % output
import subprocessimport syscmd = "cmd.exe"begin = 101end = 102while begin < end: ##blow for windows shell chinese show## #reload(sys) #sys.setdefaultencoding('utf-8') print "excution result start :\n" child = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) print "ping -n 1 -w 100 192.168.1." + str(begin) + "\n" child.stdin.write("ping -n 1 -w 100 192.168.1." + str(begin) + "\n") child.stdin.close() child.wait() print "excution result end:\n" begin += 1 #print child.stdout.readlines() for line in child.stdout.readlines(): ##blow for pycharm and cygwin show chinese# output = line.decode('cp936').encode('utf-8') print "%s\n" % output
阅读全文
0 0
- Python下使用subprocess中文乱码的解决方案
- Python下使用subprocess中文乱码的解决方案
- 【可行】windows下使用vim显示中文乱码的解决方案
- python的subprocess模块使用
- python下的MySQLdb使用+乱码的解决方案
- Python的Print打印中文乱码解决方案
- python 输出中文乱码的解决方案
- Python的Print打印中文乱码解决方案
- ubuntu命令行下中文乱码的解决方案
- ubuntu命令行下中文乱码的解决方案
- 中文乱码的解决方案:
- selenium使用python的csv进行参数化时,中文乱码解决方案
- Python中subprocess模块的使用
- Python中subprocess模块的使用
- Python中subprocess模块的使用
- Python之subprocess模块的使用
- Ubuntu下中文乱码解决方案
- $.ajax下中文乱码解决方案
- Button
- 《利用Python进行数据分析》笔记---第2章--1880-2010年间全美婴儿姓名
- FCN新手笔记,如何训练自己的模型
- API
- ImageView
- Python下使用subprocess中文乱码的解决方案
- 数字信号处理实验(一)
- validate表单验证用法 (一)
- STL之map应用 回文串
- Text
- null pointer exception
- 避免在设置中强制停止某一应用
- Azure上部署的资源公网连通性测试工具-paping
- 1.颜色空间缩减算法使用