os.popen problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: os.popen problem (/thread-41873.html) |
os.popen problem - thefrog - Mar-31-2024 I'm trying to work on os.popen When I try to do an ipconfig command, it gives me an error alert Any other command for example ping 8.8.8.8 works great Can someone help me understand why this is happening to me RE: os.popen problem - snippsat - Mar-31-2024 Use subprocess and advise run() function for all use cases it can handle.import subprocess result = subprocess.run(['ipconfig'], encoding='utf-8', capture_output=True) print(result.stdout)No force it to utf-8 (Python's default encoding),Windows can sometime use charmap encoding when call external stuff.
|