python小白,在看廖雪峰pythonsubprocess教程的时候碰到下面一个执行nslookup命令的报错操作系统:win10python版本:3.7importsubprocessprint('$nslookup')p=subprocess.Popen(['nslookup'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)output,err=p.communicate(b'setq=mx\npython.org\nexit\n')print(output.decode('utf-8'))print('Exitcode:',p.returncode)报错信息:$nslookupTraceback(mostrecentcalllast):File"E:/py/learning-python/Process_Thread/multi_process/sub_process.py",line14,in print(output.decode('utf-8'))UnicodeDecodeError:'utf-8'codeccan'tdecodebyte0xc8inposition2:invalidcontinuationbyteProcessfinishedwithexitcode1请问造成这个错误的原因是什么?如何解决谢谢。
神不在的星期二
相关分类