0

このコードを使用してサブプロセスを実行し、コマンド ウィンドウに whats の出力を出力する必要があります。

import subprocess

msprompt = 'C:\Windows\Microsoft.NET\Framework64\\v4.0.30319\\MSBuild.exe'
path = "C:/Users/bgb/Documents/Brent/Code/Visual Studio/tree.DataManagement.UnitTests./tree.DataManagement.UnitTests.vbproj"

def command(msprompt, openFile):

    for line in finalPathList:


        p = subprocess.Popen([msprompt, path], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        for line in p.stdout.readlines():
            print line,
        retval = p.wait()

これをコンパイラで実行すると、機能しません。次のメッセージが表示されます。

MSBUILD : error MSB1009: Project file does not exist.
Switch: "C:/Users/bgb/Documents/Brent/Code/Visual Studio/tree.FormControls.UnitTests./tree.FormControls.UnitTests.vbproj"

ただし、コマンドウィンドウを完全に個別に開き、mspromptコピーして貼り付けてから、コマンドウィンドウにコピーして貼り付けてEnterキーを押すと、完全に機能します。関数pathで何を台無しにしているか知っている人はいますかcommand??

助けていただければ幸いです。

4

1 に答える 1

1

パスの形式が間違っていると思います。スラッシュ\\ではなく 2 つのバック スラッシュを使用する必要があります/

デバッグの目的で、を使用してみてos.path.exists(path)、最初にパスが正しいことを確認してください。os.path.joinその後、パスを修正するために使用できます (ドキュメントはこちら)。

于 2013-05-20T19:02:59.420 に答える