Discussion:
error in os.popen result
Liam Marsh
2014-07-01 16:31:22 UTC
Permalink
hello, for a small server program, I wanted to know which ports were
occuped.
with the dos command 'netstat'
so I tried this:

*>>>a=os.popen('netstat')*
*>>>bytes(a.read())*

but this occured in the second step:

*Traceback (most recent call last):*
* File "<pyshell#20>", line 1, in <module>*
* bytes(a.read())*
* File "C:\Apps\Programmation\Python3.2\lib\encodings\cp1252.py", line 23,
in decode*
* return codecs.charmap_decode(input,self.errors,decoding_table)[0]*
*UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 79:
character maps to <undefined>*

*how can I avoid it and why does the windows cmd does return an
undecodable character?*

*thank you.*
Steven D'Aprano
2014-07-01 17:04:22 UTC
Permalink
Hello Liam,

This is a mailing list for discussing possible future ideas for the next
version of Python, not for general support.

I recommend that you use the python-list-+ZN9ApsXKcEdnm+***@public.gmane.org mailing list, also
available via Usenet on comp.lang.python.

Good luck.
Post by Liam Marsh
hello, for a small server program, I wanted to know which ports were
occuped.
with the dos command 'netstat'
*>>>a=os.popen('netstat')*
*>>>bytes(a.read())*
*Traceback (most recent call last):*
* File "<pyshell#20>", line 1, in <module>*
* bytes(a.read())*
* File "C:\Apps\Programmation\Python3.2\lib\encodings\cp1252.py", line 23,
in decode*
* return codecs.charmap_decode(input,self.errors,decoding_table)[0]*
character maps to <undefined>*
*how can I avoid it and why does the windows cmd does return an
undecodable character?*
*thank you.*
_______________________________________________
Python-ideas mailing list
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/
Loading...