Configure IPython to use powershell instead of cmd

后端 未结 3 835
青春惊慌失措
青春惊慌失措 2021-02-19 10:45

Searched for this, and couldn\'t seem to find anyone who\'d already asked, so here goes.

I\'m starting to switch over to IPython as my go-to shell on Windows 7, and I\'d

3条回答
  •  情话喂你
    2021-02-19 11:21

    It is a little bit dodgy, but you could resort to calling pre-made powershell scripts using

    os.system('powershell C:\file.ps1')

    or individual commands like so:

    os.system("powershell; gci | where {$_.Fullname -contains 'some stuff'}")

    EDIT:

    I just tested this, and it seems to only have to open a single powershell instance:

    os.system("powershell; gci; gc C:\windows\system32\drivers\etc\services; [system.net.dns]::gethostbyaddress('203.20.74.6') | more")

    but I guess it could get ugly and slow if you had to call this type of thing many times in a script.

提交回复
热议问题