Python下使用subprocess中文乱码的解决方案
来源:互联网 发布:微信h5软件 编辑:程序博客网 时间:2024/05/17 22:23
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下中文乱码解决方案
- 基于TT 双WAN固件(dualwan)下的QOS脚本 很给力
- Eclipse经常卡死的解决办法
- xcode8 libpng error: CgBI: unhandled critical chunk
- js组织架构图
- Java异常体系及异常处理
- Python下使用subprocess中文乱码的解决方案
- Android中的AIDL
- recycleview条目的背景选择器
- python中的yield简单使用
- bootbox
- Swift3.0中文教程:1.基础部分
- Android之动画效果编程基础
- 自定义隐式转换 public static implicit operator 和显式转换
- Android 过度绘制优化措施