[問題] 如何呼叫 c++/c# 執行檔

看板Python作者 (jlindeberg)時間8年前 (2018/01/15 21:22), 編輯推噓2(204)
留言6則, 4人參與, 8年前最新討論串1/1
請問一下 python 要怎麼呼叫 C++或C#執行檔? 試著用 subprocess: cmd = 'program1.exe' retcode = subprocess.call(cmd, shell=True) 但是傳回 'program1.exe' is not recognized as an internal or external command, operable program or batch file. 請問要怎麼用相對位址去呼叫其他程式? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 110.50.140.106 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1516022555.A.BF4.html

01/15 21:45, 8年前 , 1F
用絕對位置是最可靠的方法, 目前所在的檔案位置可以用
01/15 21:45, 1F

01/15 21:45, 8年前 , 2F
__file__ 變數拿到
01/15 21:45, 2F

01/15 21:46, 8年前 , 3F
再搭配 os.path 或 pathlib 轉成絕對位置
01/15 21:46, 3F

01/15 23:04, 8年前 , 4F
樓上正確
01/15 23:04, 4F

01/15 23:32, 8年前 , 5F
Shell=False
01/15 23:32, 5F

01/16 22:03, 8年前 , 6F
好的 謝謝
01/16 22:03, 6F
文章代碼(AID): #1QNAiRlq (Python)