python.exe and pythonw.exe give different results for the same script ,what happened?

522 Views Asked by At
def log_file(file, *args):
    with open(file, 'w', encoding='utf-8') as file:
        file.write(' '.join([*args, '\n']))


def command_true(*args):
    from subprocess import run, PIPE,STDOUT
    from os.path import exists
    return run(args, shell=True, stdout= PIPE, text=True).stdout

import os

os.chdir('//192.168.1.1/c/code') # after I remove this line both gives right results .
log_file('C:/test.log', command_true('getmac'))

python.exe gives result as below .

物理地址            传输名称                                                  
=================== ==========================================================
82-66-A9-F4-BD-6B   \Device\Tcpip_{F57C2513-EB2A-4867-8A24-94A91957546B}      
92-3E-3B-28-80-28   暂缺                                                      
 

pythonw.exe gives empty result .

(nothing at all)

after i remove os.chdir('//192.168.1.1/c/code'), both gives right results ,

(FYI :getmac is a windows command to get nic adddresses , '//192.168.1.1/c/code' is empty ,if I ran this script with pycharm ,both python and pythonw interpreter gives right results)

why ,how to fix it ?

0

There are 0 best solutions below