python小白,在看廖雪峰python subprocess
教程的时候碰到下面一个执行 nslookup
命令的报错
操作系统:win10 python版本:3.7
import subprocessprint('$ nslookup') p = subprocess.Popen(['nslookup'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)output, err = p.communicate(b'set q=mx\npython.org\nexit\n')print(output.decode('utf-8'))print('Exit code:', p.returncode)
报错信息:
$ nslookup Traceback (most recent call last): File "E:/py/learning-python/Process_Thread/multi_process/sub_process.py", line 14, in <module> print(output.decode('utf-8')) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 2: invalid continuation byte Process finished with exit code 1
请问造成这个错误的原因是什么?如何解决谢谢。
慕慕森
相关分类