0

メモ帳でjsonファイルとhtmlファイルを開こうとしています。次のコードがあります。

def openFile():
    fileName = listbox_1.get(ACTIVE)
    if fileName.endswith("json") or fileName.endswith("htm"):
        os.system("notepad.exe" + fileName)
    elif fileName.endswith("jpeg"):
        os.startfile(fileName)
    else:
        messagebox.showerror(title="Error", message="File is not relevant, please choose one with a directory")

問題は、現時点では、コマンド プロンプト ウィンドウが約 1 秒間点滅してから消えることだけです。ファイルの内容をメモ帳に表示する必要があります。

Windowsでpython 3.3を使用する

前もって感謝します

4

1 に答える 1

0

system通話中のスペースを逃しました。提案された修正:

os.system('notepad.exe {}'.format(fileName))
于 2013-02-24T18:47:00.327 に答える